This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/57180] New: Structures with a flexible arrray member have wrong size


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57180

             Bug #: 57180
           Summary: Structures with a flexible arrray member have wrong
                    size
    Classification: Unclassified
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: amodra@gmail.com
                CC: algrant@acm.org, amodra@gmail.com,
                    fredrickprashanth@gmail.com, gcc-bugs@gcc.gnu.org,
                    lauro.venancio@gmail.com, qrczak@knm.org.pl,
                    sbsiddha@gmail.com
        Depends on: 28865


+++ This bug was initially created as a clone of Bug #28865 +++

Cloned from 28865, because the problem is more than just getting .size wrong.
The following testcase fails on all targets at all optimization levels.
The testcase was taken from glibc/nss/nss_files/files-init.c, which is
miscompiled on powerpc or any other target using -fsection-anchors.

union
{
  struct { long j; char c[]; } s;
  char pad[32];
} x[2] =
{
  { .s = { .c = "abc123" } },
  { .s = { .c = "xyz" } }
};

int
main (void)
{
  if (sizeof (x[0]) != 32)
    __builtin_abort ();
  if (x[1].s.c[0] != 'x')
    __builtin_abort ();
  return 0;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]