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]
Other format: [Raw text]

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


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