Eric Blake <[EMAIL PROTECTED]> writes: >>> "../../lib/regexec.c", line 1412: warning: non-constant initializer: op "--" >> >> I don't understand this one. Here's the line in question: >> >> Idx num = --fs->num; >> >> and I assume Idx is size_t, which is a 32-bit unsigned integer, so this >> code should be perfectly fine C89. Am I missing something? It appears >> to me to be a compiler bug. > > I don't have the actual C89 or C99 standards in front of me at the moment, > but this line in the C99 draft explains it: > > 6.7.8 Initialization > [#2] No initializer shall attempt to provide a value for an > object not contained within the entity being initialized.
I suspect that's talking about something different, e.g.: int a[10] = { [20] = 0 }; It certainly can't be talking about expressions that contain side effects, otherwise initializations like this wouldn't be allowed: int c = getchar (); > I believe it is a gcc extension that allows you to change the value of an > unrelated variable inside an initializer. I don't think so. I think that code is portable K&R C code, as well as being portable C89 and C99 code, if the item being initialized is a scalar. Pre-C99 did have special rules for initializing aggregate types (initializers had to be constants), and my guess is that the compiler is confused and is thinking that Idx is a structure. Or maybe it thinks Idx is 'long long' and that the 'long long' type is a structure? Some earlier Sun C compilers had that bug.