C
Christian Christmann
Hi,
I want to store struct on an STL stack.
My code:
struct info {
list< ClassA* >::const_iterator itBegin;
list< ClassA* >::const_iterator itEnd;
bool b;
int c;
ClassB *ptrB;
};
int foo() {
....
stack< info > myStack;
....
}
When the program is compiled with gcc 3.4.6 and -O0, everything works fine.
However, when I compile the program with -O3 and run it, the program execution
does not finish but runs out of control and consumes all my free RAM. I
used ddd to debug the program. When the initialization of "myStack" is
performed, the program enters the STL deque class (ddd tells me that the
program flow enters stl_deque.h) and there in
template<typename _Tp, typename _Alloc>
class _Deque_base
the constructor
_Deque_base(const allocator_type& __a, size_t __num_elements)
is invoked.
Inside the constructor,
_M_initialize_map(__num_elements);
is invoked, where the program loses control (freezing and consuming my entire
memory).
Any ideas what is wrong and how I could solve the problem?
When I omit "ptrB" in the struct, the program works fine.
Thank you.
Regards,
Chris
I want to store struct on an STL stack.
My code:
struct info {
list< ClassA* >::const_iterator itBegin;
list< ClassA* >::const_iterator itEnd;
bool b;
int c;
ClassB *ptrB;
};
int foo() {
....
stack< info > myStack;
....
}
When the program is compiled with gcc 3.4.6 and -O0, everything works fine.
However, when I compile the program with -O3 and run it, the program execution
does not finish but runs out of control and consumes all my free RAM. I
used ddd to debug the program. When the initialization of "myStack" is
performed, the program enters the STL deque class (ddd tells me that the
program flow enters stl_deque.h) and there in
template<typename _Tp, typename _Alloc>
class _Deque_base
the constructor
_Deque_base(const allocator_type& __a, size_t __num_elements)
is invoked.
Inside the constructor,
_M_initialize_map(__num_elements);
is invoked, where the program loses control (freezing and consuming my entire
memory).
Any ideas what is wrong and how I could solve the problem?
When I omit "ptrB" in the struct, the program works fine.
Thank you.
Regards,
Chris