public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* [Mainline regression] ICE when throwing strings
@ 2002-10-24  9:42 Reichelt
  2002-10-24 19:18 ` Mark Mitchell
  0 siblings, 1 reply; 4+ messages in thread
From: Reichelt @ 2002-10-24  9:42 UTC (permalink / raw)
  To: gcc

Hi,

we already have at least 4 PRs for this problem, so I just wanted to bring it
to attention in order to prevent GNATS from getting flooded with more PRs of
the same issue.

Throwing an exception that uses strings will cause an ICE on
mainline (just compile with g++ -O):

----------------------snip here--------------------
#include<string>

struct C
{
    C (std::string) {}
};

void foo ()
{
    throw C(std::string());
}
----------------------snip here--------------------

A reduced testcase can be found in PR 8186 and PR 7959.
PR 8325 and PR 8244 are probably the same bug.

Greetings,
Volker


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Mainline regression] ICE when throwing strings
  2002-10-24  9:42 [Mainline regression] ICE when throwing strings Reichelt
@ 2002-10-24 19:18 ` Mark Mitchell
  2002-10-25 11:27   ` Reichelt
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Mitchell @ 2002-10-24 19:18 UTC (permalink / raw)
  To: Reichelt, gcc



--On Thursday, October 24, 2002 12:23:23 PM +0200 Reichelt 
<reichelt@igpm.rwth-aachen.de> wrote:

> Hi,
>
> we already have at least 4 PRs for this problem, so I just wanted to
> bring it to attention in order to prevent GNATS from getting flooded with
> more PRs of the same issue.
>
> Throwing an exception that uses strings will cause an ICE on
> mainline (just compile with g++ -O):
>
> ----------------------snip here--------------------
> #include<string>
>
> struct C
> {
>     C (std::string) {}
> };
>
> void foo ()
> {
>     throw C(std::string());
> }
> ----------------------snip here--------------------
>
> A reduced testcase can be found in PR 8186 and PR 7959.
> PR 8325 and PR 8244 are probably the same bug.

I know exactly what is causing this; Jason wrote some code to elide
copy constructors in this situation and it doesn't play nice with
inlining.  -fno-elide-constructors is a work-around.

Jason knows about the bug and will fix it when he is no longer at the
C++ standards meeting.

If you want, test replacing "flag_elide_constructors" with "false" in
stabilize_throw_expr; if that passes, you can go ahead and check it in
on the mainline.  That should disable the new optimization and avoid the
bug.

-- 
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Mainline regression] ICE when throwing strings
  2002-10-24 19:18 ` Mark Mitchell
@ 2002-10-25 11:27   ` Reichelt
  2002-10-25 15:25     ` Mark Mitchell
  0 siblings, 1 reply; 4+ messages in thread
From: Reichelt @ 2002-10-25 11:27 UTC (permalink / raw)
  To: mark, gcc

On 24 Oct, Mark Mitchell wrote:
> 
> 
> --On Thursday, October 24, 2002 12:23:23 PM +0200 Reichelt 
> <reichelt@igpm.rwth-aachen.de> wrote:
> 
>> Hi,
>>
>> we already have at least 4 PRs for this problem, so I just wanted to
>> bring it to attention in order to prevent GNATS from getting flooded with
>> more PRs of the same issue.
>>
>> Throwing an exception that uses strings will cause an ICE on
>> mainline (just compile with g++ -O):
>>
>> ----------------------snip here--------------------
>> #include<string>
>>
>> struct C
>> {
>>     C (std::string) {}
>> };
>>
>> void foo ()
>> {
>>     throw C(std::string());
>> }
>> ----------------------snip here--------------------
>>
>> A reduced testcase can be found in PR 8186 and PR 7959.
>> PR 8325 and PR 8244 are probably the same bug.
> 
> I know exactly what is causing this; Jason wrote some code to elide
> copy constructors in this situation and it doesn't play nice with
> inlining.  -fno-elide-constructors is a work-around.
> 
> Jason knows about the bug and will fix it when he is no longer at the
> C++ standards meeting.
> 
> If you want, test replacing "flag_elide_constructors" with "false" in
> stabilize_throw_expr; if that passes, you can go ahead and check it in
> on the mainline.  That should disable the new optimization and avoid the
> bug.

The good news is that -fno-elide-constructors makes things work for all
four PRs.

The bad news is that your proposed patch, which I implemented in the
following way

----------------------------------------------------------------------
diff -up gcc/gcc/cp/except.c gcc-new/gcc/cp/except.c
--- gcc/gcc/cp/except.c	Fri Oct 25 10:16:49 2002
+++ gcc-new/gcc/cp/except.c	Fri Oct 25 10:16:44 2002
@@ -587,6 +587,9 @@ stabilize_throw_expr (exp, initp)
 {
   tree init_expr;
 
+#if 0
+  /* Disabled, because we get ICEs when throwing strings (see PR 8186).  */
+
   if (TREE_CODE (exp) == TARGET_EXPR
       && TREE_CODE (TARGET_EXPR_INITIAL (exp)) == AGGR_INIT_EXPR
       && flag_elide_constructors)
@@ -610,6 +613,7 @@ stabilize_throw_expr (exp, initp)
       TREE_OPERAND (aggr_init, 1) = newargs;
     }
   else
+#endif
     {
       exp = stabilize_expr (exp, &init_expr);
     }
----------------------------------------------------------------------

causes 3 regressions in the testsuite:

FAIL: g++.eh/ctor1.C referenced below (test for errors, line 4)
FAIL: g++.eh/ctor1.C can't copy (test for errors, line 12)
FAIL: g++.eh/ctor1.C (test for excess errors)

Should we prepare a patch to disable this optimization altogether
or rather wait for Jasons return?
Any thoughts?

Greetings,
Volker Reichelt


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Mainline regression] ICE when throwing strings
  2002-10-25 11:27   ` Reichelt
@ 2002-10-25 15:25     ` Mark Mitchell
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Mitchell @ 2002-10-25 15:25 UTC (permalink / raw)
  To: Reichelt, gcc


>
> causes 3 regressions in the testsuite:
>
> FAIL: g++.eh/ctor1.C referenced below (test for errors, line 4)
> FAIL: g++.eh/ctor1.C can't copy (test for errors, line 12)
> FAIL: g++.eh/ctor1.C (test for excess errors)
>
> Should we prepare a patch to disable this optimization altogether
> or rather wait for Jasons return?

Those failures are pretty innocuous compared to the current state;
they are just missed errors, as opposed to rejection of a valid
program.  And, they are already present if you use
"-fno-elide-constructors" by hand.

So, please go ahead and check in your patch, file a high-priority PR a
bout the new problem (the ctor1.C failure), and make Jason aware of that
new PR as well.

Thanks,

-- 
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-10-25 16:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-24  9:42 [Mainline regression] ICE when throwing strings Reichelt
2002-10-24 19:18 ` Mark Mitchell
2002-10-25 11:27   ` Reichelt
2002-10-25 15:25     ` Mark Mitchell

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).