c++-sig@python.org
[Top] [All Lists]

Re: [C++-sig] boost/python 1.33.1 breaks aliasing rules

Subject: Re: [C++-sig] boost/python 1.33.1 breaks aliasing rules
From: David Abrahams
Date: Sat, 24 Jun 2006 09:21:56 -0400
"Ralf W. Grosse-Kunstleve" <rwgk@xxxxxxxxx> 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

_______________________________________________
C++-sig mailing list
C++-sig@xxxxxxxxxx
http://mail.python.org/mailman/listinfo/c++-sig

<Prev in Thread] Current Thread [Next in Thread>