This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Aliasing bug in GCC 4.3.1? Resolved in 4.3.3?
- From: Andrew Haley <aph at redhat dot com>
- To: Andreas Lubensky <theNfan at gmx dot de>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sat, 21 Mar 2009 16:13:46 +0000
- Subject: Re: Aliasing bug in GCC 4.3.1? Resolved in 4.3.3?
- References: <200903211450.10679.theNfan@gmx.de>
Andreas Lubensky wrote:
> Hello,
> i worked with g++ 4.3.1 (linux/586) and experienced some aliasing issues.
> Basically, i have a base class and an derived class and i am doing downcasts
> in a number of places using static_cast<derived*>(base_pointer) (no other
> casting is involved, except implicit casting from derived* to base*).
> To my understanding, this should not be a problem, since both types are
> related.
> Nevertheless, using -O2 or -O3 resulted in broken code. Apparently the order
> of execution was mixed up in some places. Using -fno-strict-aliasing or
> applying the may_alias attribute to these classes resolved the problem.
> The whole issue is very hard to reproduce, so i could not boil it down to a
> simple example (as the optimizer propably acts very unpredictable on
> different code).
> I did not have this problem using some GCC 4.1 and 4.2. I just upgraded to
> 4.3.3 and the problem vanished again.
> Nevertheless, i am worried the bug just *happens* to not show up, because the
> optimizer may work a little different.
> So: are there any aliasing issues that are known to be explicitly resolved by
> 4.3.3?
It's hard to know exactly what caused your problem, but yes, there are a
number of aliasing changes on the 4.3 branch: I counted twelve patches.
Andrew.