[cfe-dev] [PATCH] Fix for bug 21725: wrong results with union and strict-aliasing

Jeroen Dobbelaere jeroen.dobbelaere at gmail.com
Thu Mar 19 04:49:00 PDT 2015


On Wed, Mar 18, 2015 at 8:02 PM, Daniel Berlin <dberlin at dberlin.org> wrote:

>
>
> [...]
> However, another point to consider is that, "C++ standard experts, at
> least on the GCC side, did not view this as saying "all accesses must have
> an explicit union access", but that..." may not be a reasonable reading of
> the standard. The text says, "If a program attempts to access the stored
> value of an object through a glvalue of other than one
>
>> of the following types the behavior is undefined: ...", and so I read
>> that as saying that the access must be through a glvalue of an aggregate or
>> union type (with a relevant type as one of its members). So the union or
>> aggregate type *must* be explicitly present in the access. I don't believe
>> any other interpretations, especially those which imply non-local effects,
>> are reasonable.
>>
>> Exactly what rule did GCC implement?
>>
>
> If you use an explicit union access, it assumes they alias,  otherwise,
> all bets are off.
>
> Note: As you all know, I have really no dog in this fight, nor am i a
> language lawyer. Among other things, i'm an aliasing guy. I just do the
> edge of  what the language lawyers tell me is allowed :)
>
>
I propose that we implement the same behavior in llvm.
I'm quite busy right now, but I'll try to come up with some examples later
today for which we can then annotate what kind of behavior the standard
would allow (using Richards interpretation), what gcc is doing, what we
want to do.

Greetings,

Jeroen Dobbelaere
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150319/7c681963/attachment.html>


More information about the cfe-dev mailing list