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

--- Comment #7 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> As in, I would expect that:
> 
> struct foo __attribute__((scalar_storage_order("big-endian")))
> {
>     uint32_t bar;
> } foo;
> 
> uint32_t *baz = &foo.bar;
> 
> ... would give an error on a littleendian architecture and a warning on a
> bigendian architecture, however, at this point it seems to be completely
> quiet about it.

Well, the above code doesn't even compile, so please post compilable stuff.

For example:

struct __attribute__((scalar_storage_order("big-endian"))) S1
{
  int i;
};

struct __attribute__((scalar_storage_order("little-endian"))) S2
{
  int i;
};

int *addr1 (int which, struct S1 *s1, struct S2 *s2)
{
  return (which == 1 ? &s1->i : &s2->i);
}

eric@polaris:~/build/gcc/native> gcc/xgcc -Bgcc -S sso-2.c
sso-2.c: In function 'addr1':
sso-2.c:13:24: error: cannot take address of scalar with reverse storage order
   return (which == 1 ? &s1->i : &s2->i);
                        ^

> Finally, the section in the manual about type-punning in the presence of
> this attribute is very opaque to me.  I am not sure what it means is allowed
> or disallowed, or how things would work in the presence of casts.

Everything works if you don't try to toggle the storage order.

Reply via email to