From: LRN <lr...@gm...> - 2009-08-14 19:24:02
|
I was wondering about STL. There seems to be a strange feature that i do not understand. I hope that someone will help me to use it properly. I'm trying to build and run a simple program that links to llvm and clang. These two are known to use STL a lot. And the program works only when it is built with -O1 or higher. When i build it with -O0, it builds fine, and runs, but freezes along the way, running in an infinite loop. I've tracked the loop to std::__destroy_aux, lines 121 and 122 ("for (; __first != __last; ++__first)" and "std::_Destroy(&*__first);") When the process enters the line 121 (i'm using gdb, by the way), __first == 0x1461768, __last == =0x1461770, sizeof(*__first) == 8 after a single 's' gdb steps to the line 122. And when i evaluate __first there, its value is 0x1461778 Because it jumped over 0x1461770, the loop never ends. I've tracked this both in -O0 and -O1 builds. In -O0 everything happens just as i described. In -O1 however the pointer is incremented by 8, not by 16, and the loop ends correctly So, how is this possible and how can i disable this feature? I'd really like to use -O0 builds for debugging. gcc.exe (GCC) 4.2.4 (TDM-1 for MinGW) at the moment Observed the same behaviour with 4.2.1 (although i couldn't find C++ headers for that one, so i have probably used headers from some other version) Also, this feature doesn't want to reappear in any tescases i've tried to create, no matter how complex. I was never good at testcases though :) |