https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43311

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
               Host|x86_64-gnu-linux            |
              Build|x86_64-gnu-linux            |

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Zdenek Sojka from comment #5)
> (In reply to comment #4)
> > 
> > No, s.b2 should be 1.
> 
> Thank you for the answer. In that case, the optimisation in comment #0 can't
> be done in a general case (unless I have overlooked something).

Right this makes the code wrong if we do this, an aliasing issue. 

But this is well defined to do:
typedef struct { unsigned char b1, b2; } __attribute__((aligned(8))) S;
void f( S const* __restrict__ s, unsigned char* __restrict__ b1, unsigned char*
__restrict__ b2 )
{
        *b1 = s->b1;
        *b2 = s->b2;
}

Reply via email to