This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: bug or feature?
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- To: Aldy Hernandez <aldyh at redhat dot com>
- Cc: GCC Mailinglist <gcc at gcc dot gnu dot org>
- Date: Fri, 2 May 2003 20:14:45 +0100 (BST)
- Subject: Re: bug or feature?
- References: <8B4B9497-7CD0-11D7-B083-000393750C1E@redhat.com>
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