This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
gcc v msvc anomaly
- From: Sisyphus <kalinabears at iinet dot net dot au>
- To: gcc <gcc-help at gcc dot gnu dot org>
- Date: Thu, 27 Jan 2005 21:59:26 +0000
- Subject: gcc v msvc anomaly
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