gcc optimization and boost::any
Is anyone aware of a bug/quirk in boost::any that is exposed by GCC optimization? (Or vice versa: a bug in GCC optimization exposed by boost::any)? We've got a particularly insidious runtime bug that appears under `-O2` with gcc version 4.2.2, but not with gcc 3.3.3, and not with gcc 4.3.3. We narrowed it down to a single .cpp file, which contains a single method, which does nothing but call boost::any_cast several times to extract a pointer from a boost::any instance. By compiling this file under -O2, (gcc version 4.2.2) we can cause the bug. By compiling without any `-O` flags, the bug does not appear. (boost version 1_34_1). We're working to identify a minimal test case that we can post here. We still haven't pinpointed the exact cause. To be clear, we're not 100% sure the bug is in boost::any or gcc -- it merely appears to be so since changing compiler flags or compiler versions makes the bug disappear. If you know of such a bug or quirk in either GCC or boost::any, or of a write-up of this somewhere... or even some idle speculation... it could save us a lot of time tracking this down. Thanks, -John
John wrote:
If you know of such a bug or quirk in either GCC or boost::any, or of a write-up of this somewhere... or even some idle speculation... it could save us a lot of time tracking this down.
Don't know anything off-hand but valgrind may be able to pinpoint where something is going wrong. -- Sohail Somani http://uint32t.blogspot.com
For a possible fix (however quick and dirty as it may be), you could try to
switch to using boost::variant instead (if at all possible).
If it makes sense to use boost::variant in you context you might as well be
satisfied with that.
Another thing that could be checked is that the code involved with the any
is compiled with the same compiler version and boost version (a minimal test
will of course help to identify such a problem)
--
Rune
On Sun, Mar 15, 2009 at 6:42 PM, Sohail Somani
John wrote:
If you know of such a bug or quirk in either GCC or boost::any, or of a write-up of this somewhere... or even some idle speculation... it could save us a lot of time tracking this down.
Don't know anything off-hand but valgrind may be able to pinpoint where something is going wrong.
-- Sohail Somani http://uint32t.blogspot.com
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Just to follow up: It appears to be a bug in gcc's -fgcse optimization (which is enabled by -O2). Toggling -fno-gcse on gcc 4.2.2 eliminates the symptoms. The code in question is simple enough, and there were enough bugs reported against -fgcse, that we are content to let the blame fall on -fgcse, and move on. Thanks for the suggestions. Rune Lund Olesen wrote:
For a possible fix (however quick and dirty as it may be), you could try to switch to using boost::variant instead (if at all possible).
If it makes sense to use boost::variant in you context you might as well be satisfied with that.
Another thing that could be checked is that the code involved with the any is compiled with the same compiler version and boost version (a minimal test will of course help to identify such a problem)
-- Rune
On Sun, Mar 15, 2009 at 6:42 PM, Sohail Somani
mailto:sohail@taggedtype.net> wrote: John wrote: > If you know of such a bug or quirk in either GCC or boost::any, or of a > write-up of this somewhere... or even some idle speculation... it could > save us a lot of time tracking this down.
Don't know anything off-hand but valgrind may be able to pinpoint where something is going wrong.
-- Sohail Somani http://uint32t.blogspot.com
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org mailto:Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
John
-
Rune Lund Olesen
-
Sohail Somani