public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/26143] New: [4.0 Regression] wrong code when returning a function pointer
@ 2006-02-07 0:26 halcy0n at gentoo dot org
2006-02-07 0:37 ` [Bug c++/26143] " pinskia at gcc dot gnu dot org
2006-02-07 2:36 ` [Bug c++/26143] accepts invalid function pointer type return pinskia at gcc dot gnu dot org
0 siblings, 2 replies; 3+ messages in thread
From: halcy0n at gentoo dot org @ 2006-02-07 0:26 UTC (permalink / raw)
To: gcc-bugs
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:
halcyon@birdbath ~ $ ./a.out
*** glibc detected *** free(): invalid pointer: 0xb7e6cfe8 ***
Aborted
Results with 4.1:
halcyon@birdbath ~ $ ./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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-02-07 2:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-07 0:26 [Bug c++/26143] New: [4.0 Regression] wrong code when returning a function pointer halcy0n at gentoo dot org
2006-02-07 0:37 ` [Bug c++/26143] " pinskia at gcc dot gnu dot org
2006-02-07 2:36 ` [Bug c++/26143] accepts invalid function pointer type return pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).