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/53196] unknown struct name in C99 compound initializer doesn't generate error


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

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-05-02 21:17:01 UTC ---
(In reply to comment #3)
> (In reply to comment #2)
> > That's simply because compound literals aren't valid in C++.
> 
> So this page is wrong? 
> http://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html

I didn't realise it was claimed to work in C++, but yes, I guess the docs are
wrong.  C++ provides several portable forms of initialization, there's really
no need to support another non-standard one.

These will all work for aggregate types (including "C structs")

foo f{};
foo f = {};
foo f = foo{};
foo f = foo();

I'll propose a patch to fix the docs.


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