473,396 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Is this code standard ?

I have a very small program which will not compile. I was wondering if
i was doing something that violated the c++ standard itself. (for
those interested, I am using g++ 3.4.3)

This program will not compile: (Internal ERROR : Segmentation Fault)

(#include<vectorfor all of the following)

class myClass
{
std::vector<floatm_buffer[75000];
};
int main()
{
//NOTHING
}

// But this one will:
int main()
{
// I can increase this size hugely without problem, so memory is not
the issue here.
std::vector<floatm_buffer[75000];
}

This one also works fine:
class myClass
{
std::vector<floatm_buffer;
};
int main()
{
myClass obj[75000]; // Which seems to be equivalent to the first
program
}

Should the first program compile ?

Jan 15 '07 #1
3 1248
joseph cook wrote:
I have a very small program which will not compile. I was wondering if
i was doing something that violated the c++ standard itself. (for
those interested, I am using g++ 3.4.3)

This program will not compile: (Internal ERROR : Segmentation Fault)
That means there is a bug in the compiler. It should never bail out with
an "internal error". Of course, it could still be a response to erroneous
code, but that doesn't seem to be the case here.
(#include<vectorfor all of the following)

class myClass
{
std::vector<floatm_buffer[75000];
You want an array of 75000 vectors of float?
};
int main()
{
//NOTHING
}

// But this one will:
int main()
{
// I can increase this size hugely without problem, so memory is not
the issue here.
std::vector<floatm_buffer[75000];
}

This one also works fine:
class myClass
{
std::vector<floatm_buffer;
};
int main()
{
myClass obj[75000]; // Which seems to be equivalent to the first
program
}

Should the first program compile ?
Yes. With g++ 4.1, it does.
Jan 15 '07 #2
You want an array of 75000 vectors of float?

Sure do.
Thanks for your response

Jan 15 '07 #3
joseph cook wrote:
I have a very small program which will not compile. I was wondering if
i was doing something that violated the c++ standard itself. (for
those interested, I am using g++ 3.4.3)

This program will not compile: (Internal ERROR : Segmentation Fault)

(#include<vectorfor all of the following)

class myClass
{
std::vector<floatm_buffer[75000];
};
int main()
{
//NOTHING
}
Works with g++ (GCC) 3.3.5.

--
Ron House ho***@usq.edu.au
http://www.sci.usq.edu.au/staff/house
Ethics website: http://www.sci.usq.edu.au/staff/house/goodness
Jan 17 '07 #4

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

Similar topics

242
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any...
67
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
253
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any...
7
by: Skybuck Flying | last post by:
Hi, if (__builtin_expect (!buffer->__init, 0)) { buffer->__a = 0x5deece66dull; buffer->__c = 0xb; buffer->__init = 1; } I am using visual c 6 and this code doesn't compile, it's probably...
27
by: George2 | last post by:
Hello everyone, Should I delete memory pointed by pointer a if there is bad_alloc when allocating memory in memory pointed by pointer b? I am not sure whether there will be memory leak if I do...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.