This is the mail archive of the gcc@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]

Labeled initializer elements mishandled


The C++ compiler mishandles labeled elements in initializers, ie. it
effectively ignores the labels.

$ cat init.cc
struct X { int a, b; };

struct X f (int a, int b)
{
  struct X y = { b: b, a: a };
  return y;
}

int main ()
{
  struct X x = f (42, 0);
  if (x.a != 42 || x.b != 0)
    abort ();
  exit (0);
}
$ gcc init.cc
$ ./a.out
Aborted (core dumped)

-- 
Andreas Schwab                                      "And now for something
schwab@issan.informatik.uni-dortmund.de              completely different"
schwab@gnu.org


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