gcc v msvc anomaly
Sisyphus
kalinabears@iinet.net.au
Thu Jan 27 23:05:00 GMT 2005
Hi,
--- alloc.c ---
#include <stdio.h>
int main() {
int i, c = 5, j[c];
for(i = 0; i < c; ++i) {
j[i] = i;
printf("%d ", j[i]);
}
printf("\n");
return 0;
}
--------------
Should that simple script compile and run as expected ?
With my MinGW port of gcc it does - but with Microsoft compilers it
won't even compile. I get:
alloc.c(4) : error C2057: expected constant expression
alloc.c(4) : error C2466: cannot allocate an array of constant size 0
alloc.c(4) : error C2133: 'j' : unknown size
Is the Microsoft compiler right in rejecting the code ? If so, has the
issue been addressed in later versions of gcc ?
Cheers,
Rob
More information about the Gcc-help
mailing list