Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Is this code standard ?

Reply
Thread Tools

Is this code standard ?

 
 
joseph cook
Guest
Posts: n/a
 
      01-15-2007
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<vector> for all of the following)

class myClass
{
std::vector<float> m_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<float> m_buffer[75000];
}

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

Should the first program compile ?

 
Reply With Quote
 
 
 
 
Rolf Magnus
Guest
Posts: n/a
 
      01-15-2007
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<vector> for all of the following)
>
> class myClass
> {
> std::vector<float> m_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<float> m_buffer[75000];
> }
>
> This one also works fine:
> class myClass
> {
> std::vector<float> m_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.
 
Reply With Quote
 
 
 
 
joseph cook
Guest
Posts: n/a
 
      01-15-2007
> You want an array of 75000 vectors of float?

Sure do.
Thanks for your response

 
Reply With Quote
 
Ron House
Guest
Posts: n/a
 
      01-17-2007
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<vector> for all of the following)
>
> class myClass
> {
> std::vector<float> m_buffer[75000];
> };
> int main()
> {
> //NOTHING
> }


Works with g++ (GCC) 3.3.5.

--
Ron House http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.sci.usq.edu.au/staff/house
Ethics website: http://www.sci.usq.edu.au/staff/house/goodness
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
standard libraries don't behave like standard 'libraries' Sriram Srinivasan Python 13 11-12-2009 06:05 PM
What are the standard network functions provided in standard C? disappearedng@gmail.com C Programming 5 06-10-2008 08:57 PM
How to redirect a "system" standard output and standard error to avariable (Linux) Venks Ruby 5 12-06-2007 12:21 AM
add pexpect to the standard library, standard "install" mechanism. funkyj Python 5 01-20-2006 08:35 PM
How standard is the standard library? steve.leach Python 1 04-18-2005 04:07 PM



Advertisments