help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

strange difference between gcc versions


From: Christof Warlich
Subject: strange difference between gcc versions
Date: Tue, 18 Oct 2005 09:54:51 +0200
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050725)

Hi,

the following compiles with gcc 2.95.3 but gives this error
with gcc 3.4.4:

~/tmp> gcc tst.cc
tst.c: In function `int main()':
tst.c:4: error: data member may not have variably modified type `int[((unsignedint)((int)i))]'

int main(void) {
    int i = 2;
    struct X {
        int a[i];
    } x;
    return 0;
}

while

int main(void) {
    int i = 2;
    int a[i];
    return 0;
}

comiles with both gcc versions.

Any ideas why the newer gcc version only allows to create a dynamic
array, but not a dynamic type on the stack? Even more confusing,
both examples compile fine even with gcc 3.4.4 as C-module, i.e.

gcc tst.c

Christof


reply via email to

[Prev in Thread] Current Thread [Next in Thread]