[C++-sig] boost/python 1.33.1 breaks aliasing rules
David Abrahams
dave at boost-consulting.com
Sat Jun 24 15:21:56 CEST 2006
"Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com> writes:
> Coincidentally, on Python-Dev Scott David Daniels just suggested this trick to
> get rid of the "will break strict-aliasing rules" warnings:
>
>> PyObject_CallFunction((PyObject*) (void *) &PyRange_Type,
>> "lll", start, start+len*step, step)
>
> I.e. the trick is to insert an intermediate (void *) cast. It works with g++
> 4.1.0 at least. Could this be a general solution?
There's no such thing as a general solution to a warning (they're
implementation specific), and these "strict aliasing rules" are a C99
thing, and C++ is based on C89 (or C90, I forget which), and the code
above does the so it's hard to say what should be done.
Maybe reading
http://www.cellperformance.com/mike_acton/2006/06/understanding_strict_aliasing.html
would help.
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list