Using Boost.Bind/Boost.Function triggers what seems to be an aliasing bug with G++ 4.5.0. The minimal test case (including Boost.Bind and Boost.Function) is attached.
It works and no errors are detected by valgrind with either flags : -O0 -O1 -O2 -fno-inline -O2 -fno-strict-aliasing -Os It crashes whith either flags and valgrind detects invalid reads : -02 -O3 Everything works fine with gcc version 4.4.3 20100316. There are no warnings using '-W -Wall -Wextra'. Original bug report to boost mailing list : http://lists.boost.org/boost-users/2010/05/59020.php -- Summary: [4.5.0] Aliasing bug triggered by Boost.Bind/Boost.Function Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: maxime at altribe dot org GCC build triplet: ../configure --prefix=/usr --enable- languages=c,c++,fortran,objc GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44164