473,503 Members | 5,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

strange difference between gcc versions

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
Oct 18 '05 #1
1 1352
Christof Warlich wrote:
int main(void) {
int i = 2;
struct X {
int a[i];


Both nested types accessing automatic (local) variables, and arrays
dimensioned via integers that are not compile time constants, are on-topic
on a newsgroup or mailing list discussing gcc.

This newsgroup is only qualified to discuss Stardard C++, which decrees that
all arrays, without 'new', must size via compile-time constants, and that
nested classes can only access static things in the nesting class or
function.

Your trouble with g++ might be due to compiler specific extensions which ran
into the technical reasons for these restrictions.

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
Oct 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2336
by: Ryan | last post by:
Bit of an obscure one here, so please bear with me. I have two copies of a database which should be identical. Both have a complex view which is identical. I can open the views and the data is as...
5
3512
by: Neil Rutherford | last post by:
During testing of an application, i noticed a difference between SQL 2000 and SQL 7, both with identical config. In a nutshell: A table has a trigger for UPDATE and DELETE. When a column in the...
3
4566
by: Bill C. | last post by:
Hi, I've got a simple console app that just reads an XML file into a DataSet then prints out a description of each table in the DataSet, including column names and row values for each column. ...
25
3696
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's...
10
1913
by: Arno R | last post by:
Hi all Yesterday I found a strange corruption-issue that I can't solve yet or actually point my finger at. I converted an A97 app to A2k. I have done this often enough so I didn't expect trouble...
4
1800
by: Josh Carlisle | last post by:
I've been tasked with developing a document/file versioning system of sorts. Similar to a very scaled down source control system. We're integrating it very closely with an existing application so...
2
1815
by: Shelby Cain | last post by:
I'm putting 8.0 through its paces and here are a few things I've noticed on the native win32 port running on my workstation (2.0g p4 w/256 megs of ram). Here is the output of "vacuum verbose...
1
19808
by: bharathreddy | last post by:
This Article gives an introduction to VSTS Team Foundation & fundamental difference between Visual Source Safe (VSS) and VSTS Team Foundation. Team Foundation is a set of tools and technologies...
10
1610
by: silverbob | last post by:
I am replacing my Javascript-called files with SSI, and I'm getting an unexpected result with my page footer. I can really use some help with this. The footer contains a copyright (left...
0
7188
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7063
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7258
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7313
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3146
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
366
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.