STL, pointer increments and optimization

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

STL, pointer increments and optimization

lrn-2
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 :)


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: STL, pointer increments and optimization

Roger Pack
> 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.

> gcc.exe (GCC) 4.2.4 (TDM-1 for MinGW) at the moment

Have you tried 3.4.5?

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users