On Jan 11, 2008 11:38 AM, Steve Naroff <[EMAIL PROTECTED]> wrote:
> void a(void) {
> int explicit;
> int anylocal;
> static int *t = &explicit;    // error for explicit automatic variables.
> static int *a = (int[]){anylocal};    // implicit automatic variable.
> EDG and NEILCC permit this, while GCC error.
> }
>
> Is my analogy flawed? Since the compound literal can refer to any
> local variable, I don't see how it could ever be constant...

http://www.comeaucomputing.com/tryitout/ over the following:

void a(void) {
int anylocal;
static int *a = (int[]){anylocal};
}

gives the following (in C99 mode):

"ComeauTest.c", line 3: error: expression must have a constant value
  static int *a = (int[]){anylocal};
                          ^

"ComeauTest.c", line 3: warning: variable "a" was declared but never referenced
  static int *a = (int[]){anylocal};

What were you testing with?

-Eli
_______________________________________________
cfe-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

Reply via email to