Message254201
use_Py_BUILD_ASSERT_EXPR.patch looks good to me. But you should revert the change on decimal, as asked by Stefan, and I suggested to move an assertion inside the related function (see my comment on Rietveld).
"""
A library can follow the example in the comment.
#define foo_to_char(foo) \
((char *)(foo) \
+ Py_BUILD_ASSERT_EXPR(offsetof(struct foo, string) == 0))
"""
Hum ok, I know understand the "_EXPR" suffix of the macro name. Maybe it's worth to add a new #define Py_BUILD_ASSERT(expr) (void)Py_BUILD_ASSERT_EXPR(expr)" macro?
By the way, I don't know what happens if you pass a variable to Py_BUILD_ASSERT_EXPR() rather than a constant. Maybe we could use __builtin_constant_p() on GCC? Maybe it's overcomplexicated :-) |
|
Date |
User |
Action |
Args |
2015-11-06 15:36:57 | vstinner | set | recipients:
+ vstinner, skrah, python-dev, serhiy.storchaka |
2015-11-06 15:36:57 | vstinner | set | messageid: <1446824217.13.0.320221788905.issue25558@psf.upfronthosting.co.za> |
2015-11-06 15:36:57 | vstinner | link | issue25558 messages |
2015-11-06 15:36:56 | vstinner | create | |
|