Skip to content

Commit 5e9a783

Browse files
committed
MAINT: (mpfdtype) fix some compiler warnings and hopefully error
On CI gcc, remove the static assert for the alignment, since the alignment of the `mpf_field` is correct in the current storage scheme. Hopefully the static_assert was the problem on gcc?
1 parent 30e1fda commit 5e9a783

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

mpfdtype/mpfdtype/src/casts.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,9 @@ numpy_to_mpf_strided_loop(PyArrayMethod_Context *context,
182182
T *in = (T *)in_ptr;
183183
mpf_load(out, out_ptr, prec_out);
184184

185-
int res = C_to_mpfr<conv_T, T>(*in, out);
186-
// TODO: At least for ints, could flag out of bounds...
185+
C_to_mpfr<conv_T, T>(*in, out);
186+
// TODO: At least for ints, could flag out of bounds, the return value
187+
// of C_to_mpfr may help with that (it flags imprecisions).
187188
mpf_store(out_ptr, out);
188189

189190
in_ptr += strides[0];

mpfdtype/mpfdtype/src/dtype.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ new_MPFDType_instance(mpfr_prec_t precision)
4646
"storage of single float would be too large for precision.");
4747
}
4848
new->base.elsize = sizeof(mpf_storage) + size;
49-
new->base.alignment = _Alignof(mpf_storage);
49+
new->base.alignment = _Alignof(mpf_field);
5050
new->base.flags |= NPY_NEEDS_INIT;
5151

5252
return new;
@@ -242,7 +242,7 @@ PyArray_DTypeMeta MPFDType = {{{
242242
.tp_new = MPFDType_new,
243243
.tp_repr = (reprfunc)MPFDType_repr,
244244
.tp_str = (reprfunc)MPFDType_repr,
245-
.tp_getset = &mpfdtype_getsetlist,
245+
.tp_getset = mpfdtype_getsetlist,
246246
}},
247247
/* rest, filled in during DTypeMeta initialization */
248248
};

mpfdtype/mpfdtype/src/dtype.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ typedef struct {
2323
* So not storeing only those (saving 16 bytes of 48 for a 128 bit number)
2424
* removes the need to worry about this.
2525
*/
26-
static_assert(_Alignof(mpfr_t) >= _Alignof(mp_limb_t),
27-
"mpfr_t storage not aligned as much as limb_t?!");
2826
typedef mpfr_t mpf_storage;
2927

3028
extern PyArray_DTypeMeta MPFDType;

mpfdtype/mpfdtype/src/scalar.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ PyTypeObject MPFloat_Type = {
209209
.tp_repr = (reprfunc)MPFloat_repr,
210210
.tp_str = (reprfunc)MPFloat_str,
211211
.tp_as_number = &mpf_as_number,
212-
.tp_richcompare = &mpf_richcompare,
213-
.tp_getset = &mpfloat_getsetlist,
212+
.tp_richcompare = (richcmpfunc)mpf_richcompare,
213+
.tp_getset = mpfloat_getsetlist,
214214
};
215215

216216

0 commit comments

Comments
 (0)