This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
PR optimization/9630: [3.2/3.3/3.4 regression] crash with -freg-struct-returnin C++ code
- From: Steven Bosscher <s dot bosscher at student dot tudelft dot nl>
- To: gcc-gnats at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, nobody at gcc dot gnu dot org,stefan at space dot twc dot de, mark at codesourcery dot com
- Date: Wed, 12 Mar 2003 18:48:39 +0100
- Subject: PR optimization/9630: [3.2/3.3/3.4 regression] crash with -freg-struct-returnin C++ code
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9630
This PR is about wrong code when *not* optimizing.
The expected output of the test case is 2. With
GCC 3.3 (todays CVS), you get:
# gcc -lstdc++ -freg-struct-return 9630.cc
# a.out
Segmentation fault
# gcc -lstdc++ -freg-struct-return 9630.cc -O
# a.out
2
#
Could it be that this bug happens because libstdc++ was *not*
compiled with --freg-struct-return?
Say, the function that segfaults at -O0 is inlined at -O1.
Then at -O0 you pass the object of class "string" in a reg to
the library function that is not compiled with
-freg-struct-return, so it expects a pointer to the object
on the stack. and it segfaults.
Does that make sense?
I'm asking because I was cutting down a test case (from some
15000 lines to 380 now, see attachment 2 in the PR in GNATS)
when when I accidentally removed the lines:
namespace std
{
extern template class basic_string<char>;
}
and that makes the segfault magically go away...
Greetz
Steven