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++/77547] New: rejects valid C++ code with designated initializer


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

            Bug ID: 77547
           Summary: rejects valid C++ code with designated initializer
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu
  Target Milestone: ---

It is accepted by Clang.  The same code is accepted if treated as C code or if
the two struct fields are swapped: 

------------------

struct S
{
  char *p, c; 
} a = { .p = &a.c }; 

------------------


$ g++-trunk -v
Using built-in specs.
COLLECT_GCC=g++-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto
--prefix=/usr/local/gcc-trunk --disable-bootstrap
Thread model: posix
gcc version 7.0.0 20160909 (experimental) [trunk revision 240043] (GCC) 
$ 
$ g++-trunk -c small.cpp
small.cpp:4:19: sorry, unimplemented: non-trivial designated initializers not
supported
 } a = { .p = &a.c };
                   ^
$ clang++ -c small.cpp
$ 
$ gcc-trunk -c small.c
$ 
$ cat small.cpp
struct S
{
  char c, *p;
} a = { .p = &a.c }; 
$ 
$ cat small.c
struct S
{
  char c, *p;
} a = { .p = &a.c }; 
$

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