This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Compound literals extensions
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- To: <gcc at gcc dot gnu dot org>
- Date: Sat, 24 Nov 2001 13:13:21 +0000 (GMT)
- Subject: Compound literals extensions
GCC currently accepts compound literals as initializers in some places
where C99 does not permit them, as if they were the brace-enclosed
initializer lists they contain. In particular, it accepts them for
structures of static storage duration (for those of automatic storage
duration it is OK, since a single expression of the structure type is
acceptable in those cases), and for arrays. (The use for initializing
arrays is documented.)
In C99 a compound literal refers to an object (with the storage duration
of the enclosing block), and is an lvalue. This means that these are not
valid initializers; the array ones decay to pointers. Would it be
reasonable simply to make compound literals follow C99 semantics and
disallow these extensions, or do we need to keep them around?
--
Joseph S. Myers
jsm28@cam.ac.uk