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]

Re: bug or feature?


On Fri, 2 May 2003, Aldy Hernandez wrote:

> As a global, this works:
> 
> 	int x2 = (int) (char) 5;
> 
> This doesn't:
> 
> 	int x2 = (int) (char) {5};
> 
> b.c:1: error: initializer element is not constant
> 
> Bug?

Feature.  The second essentially means

	char __compound_literal = 5;
	int x2 = (int) __compound_literal;

- compound literals are not constant expressions, and only a few special
cases of them in initializers are accepted for compatibility in gnu89
mode.

-- 
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]