Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Is this code standard ? (http://www.velocityreviews.com/forums/t459842-is-this-code-standard.html)

joseph cook 01-15-2007 05:34 PM

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<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 ?


Rolf Magnus 01-15-2007 06:09 PM

Re: Is this code standard ?
 
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.

joseph cook 01-15-2007 06:29 PM

Re: Is this code standard ?
 
> You want an array of 75000 vectors of float?

Sure do.
Thanks for your response


Ron House 01-17-2007 02:52 AM

Re: Is this code standard ?
 
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 house@usq.edu.au
http://www.sci.usq.edu.au/staff/house
Ethics website: http://www.sci.usq.edu.au/staff/house/goodness


All times are GMT. The time now is 03:03 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.