public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Optimizer Problem
@ 1998-05-11 15:07 Andreas Steil - TEP (Tel. 3281)
  1998-05-11 11:37 ` Gerald Pfeifer
  1998-05-11 18:22 ` Carl Edwards
  0 siblings, 2 replies; 4+ messages in thread
From: Andreas Steil - TEP (Tel. 3281) @ 1998-05-11 15:07 UTC (permalink / raw)
  To: egcs-bugs; +Cc: egcs, wines, andreas.steil

Hello,

I am working with gcc version egcs-2.90.23 980102 (egcs-1.0.1 release) running on
Solaris 2.5.1.

Working with the stl shipped with the above release, I encountered a problem
which I summarized in a very small program, cf. attachment or annex to this mail,
which reproduces the problem using the optimizer.

Compiling said program with

g++ -Wall -O2 stl_mem.cc 
	
results in the error message

/usr/local/gnu/sol2.5.egcs/lib/g++/stl_construct.h: In function `void 
destroy<vector<vector<int,__default_alloc_template<false,0> >,__default_alloc_template<false,0> > *>(class 
vector<vector<int,__default_alloc_template<false,0> >,__default_alloc_template<false,0> > *, class 
vector<vector<int,__default_alloc_template<false,0> >,__default_alloc_template<false,0> > *)':
/usr/local/gnu/sol2.5.egcs/lib/g++/stl_construct.h:66: virtual memory exhausted

Compiling the program without optimizer, i.e. without -O2, everything works perfectly;
a.out says:

 The element [0][0][4]: 400,
 
as I expected.

Could you please help me and tell me whether the above error message is 
a consequence of 

1) a bug or 
2) my wrong understanding on the application of the stl ;-( .
 
In the first case, please let me know how the bug can be fixed. 

In the second case, please help me to refine my knowledge by briefly explaining me where
I went wrong and by changing the program in a way that it can be compiled with the option -O2.

In either case, I thank you very much in advance for your help.

Desperately seeking help, 
yours,

Andreas

////////////////////////////////////////////////////////////////////////////////////////////

#include <stl.h>
#include <iostream.h>

int main (char* argc, char* argv[]) {

vector< vector< vector<int> > > my3DVector;
vector< vector<int> >           my2DVector;
vector< int >                   my1DVector;

for ( int i = 0; i < 10; i++ ) my1DVector.push_back(100*i);

my2DVector.push_back(my1DVector);

my3DVector.push_back(my2DVector);

cout << " The element [0][0][4]: " << my3DVector[0][0][4] << endl;

}


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1998-05-11 18:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-05-11 15:07 Optimizer Problem Andreas Steil - TEP (Tel. 3281)
1998-05-11 11:37 ` Gerald Pfeifer
1998-05-11 15:57   ` Wolfgang Faber
1998-05-11 18:22 ` Carl Edwards

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).