STINNER Victor added the comment:

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 :-)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25558>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to