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++/53205] New: Compound literals don't allow empty initializer lists


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

             Bug #: 53205
           Summary: Compound literals don't allow empty initializer lists
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: redi@gcc.gnu.org


I don't care about this extension myself, but we should probably make it work
properly in C++ (see PR 40076 for another bug) or deprecate it (C++ offers
several alternative forms of initialization)

http://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html

struct foo { int i; };

int main()
{
    struct foo f = ((struct foo) { });
}

cl.cc: In function âint main()â:
cl.cc:5:22: error: expected primary-expression before âstructâ
     struct foo f = ((struct foo) { });
                      ^
cl.cc:5:22: error: expected â)â before âstructâ
     struct foo f = ((struct foo) { });
                      ^

An empty initializer list is allowed in C++, and as an extension in GNU C, so
it should probably work here.


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