GCC 3.1.1 --std=c99: initializer element is not constant ...

Joseph S. Myers jsm28@cam.ac.uk
Sun May 26 12:43:00 GMT 2002


On Sun, 26 May 2002, Craig Newell wrote:

> Lock lock = (Lock){ (void*)0 };

The compound literal (Lock){ (void*)0 } is an unnamed object of type Lock,
according to the C99 standard, not a constant expression.  That is, your
code is equivalent to

Lock unnamed_lock_init = { (void*)0 };
Lock lock = unnamed_lock_init;

which clearly involves a nonconstant initializer unnamed_lock_init.

-- 
Joseph S. Myers
jsm28@cam.ac.uk



More information about the Gcc-bugs mailing list