On 01/10/2015 20:40, Laszlo Ersek wrote: > > Also strict aliasing improves performance noticeably at least on some > > kind of code. The relaxation of strict aliasing that GCC does with > > unions would be a useful addition to the C standard, though. > > What do you mean under "relaxation of strict aliasing that GCC does with > unions"? I believe I know how unions affect this (although for details > I'd obviously have to consult the standard :)), but what are the gcc > specific parts?
I remembered wrong---it's not a relaxation of strict aliasing, it's defining what happens when a member of a union is accessed through a member of a different type. C89 makes that implementation-defined (3.3.2.3) and GCC defines the behavior the sane way: "the relevant bytes of the representation of the object are treated as an object of the type used for the access". C99 makes the other members "take unspecified values" (6.2.6.1). I have always thought this to be weaker than GCC's promise, but found out that a subsequent TR added a footnote to clarify that the desired behavior is the sane one too. C11 also has the same footnote, and no other change in this area. Paolo