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
* [Bug c++/26143] [4.0 Regression] wrong code when returning a function pointer
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 ` 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
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-07 0:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-02-07 00:37 -------
Confirmed.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu dot org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
GCC build triplet|i686-pc-linux-gnu |
GCC host triplet|i686-pc-linux-gnu |
GCC target triplet|i686-pc-linux-gnu |
Keywords| |wrong-code
Last reconfirmed|0000-00-00 00:00:00 |2006-02-07 00:37:37
date| |
Target Milestone|--- |4.0.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26143
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/26143] accepts invalid function pointer type return
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 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-07 2:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2006-02-07 02:36 -------
Actually I looked at this again and this is invalid code and we should reject
it (fixing where the const is fixes the wrong code):
struct DebugStringHolder
{
int (*get()) () const;
};
------
Related to PR 6628
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
BugsThisDependsOn| |6628
Keywords|wrong-code |accepts-invalid
Known to fail|4.0.3 |4.0.3 2.95.3 3.0.4 4.1.0
| |4.2.0
Known to work|3.4.5 4.1.0 |
Summary|[4.0 Regression] wrong code |accepts invalid function
|when returning a function |pointer type return
|pointer |
Target Milestone|4.0.3 |---
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).