Package: gcc-3.3 Version: 1:3.3.3-0pre1 Severity: normal This program:
#include <stdio.h> #include <stdlib.h> #include <string.h> int an_impure_function(void) { return rand(); } int main(void) { static char *const foo = "baz"; static int foo_len = strlen(foo); /* static int foo_len = an_impure_function(); */ printf("foo: %s, foo_len: %d\n", foo, foo_len); exit (EXIT_SUCCESS); } Builds silently and runs as expected with 'gcc -O test_const.c'. With 'gcc test_const.c' (i.e. no optimization), I get: greenwood$ gcc test_const.c test_const.c: In function `main': test_const.c:14: error: initializer element is not constant greenwood$ Replaceing the strlen call with a call of an impure function (commented out above) results in the above error whether or not -O is used. It seems to me that pure function should either always be usable in this way regardless of -O (and C200? should endorse pure attribute and mandate the behavior), or never be supported. Britton -- System Information: Debian Release: testing/unstable Architecture: i386 Kernel: Linux greenwood 2.4.23-1-k7 #1 Mon Dec 1 00:05:09 EST 2003 i686 Locale: LANG=C, LC_CTYPE=C Versions of packages gcc-3.3 depends on: ii binutils 2.14.90.0.7-3 The GNU assembler, linker and bina ii cpp-3.3 1:3.3.3-0pre1 The GNU C preprocessor ii gcc-3.3-base 1:3.3.3-0pre1 The GNU Compiler Collection (base ii libc6 2.3.2.ds1-10 GNU C Library: Shared libraries an ii libgcc1 1:3.3.3-0pre1 GCC support library -- no debconf information