The following testcase causes a segfault when compiled with 4.0.3 20060206 (with no optimizations). gcc-3.3, 3.4, and 4.1 all seem to work fine with this code. ---------
#include <iostream> std::string exception_to_debug_string(const std::exception & e) { return std::string("hey now"); } class DebugStringHolder { public: std::string (*get()) (const std::exception &) const { return &exception_to_debug_string; } }; static DebugStringHolder _instance; int main(int, char * argv[]) { try { throw std::exception(); } catch (std::exception &e) { std::cout << (_instance.get())(e) << std::endl; } } Results with 4.0: [EMAIL PROTECTED] ~ $ ./a.out *** glibc detected *** free(): invalid pointer: 0xb7e6cfe8 *** Aborted Results with 4.1: [EMAIL PROTECTED] ~ $ ./a.out hey now On 4.1 it seems it was fixed by pr #19317 -- Summary: [4.0 Regression] wrong code when returning a function pointer Product: gcc Version: 4.0.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: halcy0n at gentoo dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26143