This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: How to supress a specific kind of ansi-aliasing rules?
Diego Novillo <dnovillo@google.com> writes:
> On 6/20/07 9:09 AM, Bokhanko, Andrey S wrote:
>
> > Yes, but one can write something like this:
> >
> > p2 = (S1 *)&p1->s1_m2;
> >
> > Of course, this is a blatant violation of ANSI C standard, etc. Still, a
> > perfectly acceptable C code.
>
> No, it isn't. GCC only tries to DTRT on standard compliant code.
>
> > With violations of other ANSI aliasing rules, one has an exit:
> > -fno-strict-aliasing option. No so in this case.
>
> We don't have a switch to disable CSE at the RTL level (which is the
> pass doing this structural analysis). Volatile is just about the only
> thing that will help you here.
>
> Having said that, maybe we could consider having CSE not doing this with
> -fno-strict-aliasing, but I'm not sure if it's a good idea. What do
> others think?
I think that would be a bad idea.
As far as I can see, if we want to support code like the above, we
would have to add an option to not reorder any memory loads or stores
through different pointers. It shouldn't be part of
-fno-strict-aliasing.
Ian