Aliasing bug in GCC 4.3.1? Resolved in 4.3.3?
Andreas Lubensky
theNfan@gmx.de
Sat Mar 21 13:50:00 GMT 2009
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?
More information about the Gcc-help
mailing list