This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: g++ and aliasing bools
- From: Joe Buck <jbuck at synopsys dot COM>
- To: dan at dberlin dot org (Daniel Berlin)
- Cc: mark at codesourcery dot com (Mark Mitchell),jbuck at synopsys dot COM (Joe Buck),neil at daikokuya dot demon dot co dot uk (Neil Booth),pcarlini at unitus dot it (Paolo Carlini), gcc at gcc dot gnu dot org (gcc at gcc dot gnu dot org)
- Date: Mon, 28 Jan 2002 15:50:44 -0800 (PST)
- Subject: Re: g++ and aliasing bools
Daniel writes:
> *I* already argued that they aren't dangerous for another reason. In C,
> since they would have the same address, they would alias. In reality,
> in C++, they *don't* alias because they *don't* have the same address.
> However, it's perfectly fine to say things alias that don't.
> Thus, it's not dangerous.
Excuse me, but the whole point of strict aliasing is that certain things
are treated by the compiler based solely on their types, even if they have
the same address (for such cases it is considered a user bug). For example,
an access to an int can never alias an access to a float, period. If a
user writes code that violates this rule, it is not valid ISO C or C++,
and they need to write -fno-strict-aliasing if they want GCC to avoid
"miscompiling".
Thus for any discussion of cxx_get_alias_set, addresses DON'T MATTER.
All that matters are types and nothing else.
Now, if the compiler can separately determine that two accesses can never
have overlapping addresses, it can assume that these accesses do not
alias. But that needs to be handled elsewhere in the compiler, and not
by xxx_get_alias_set.