Bug 71100 - [6/7 regression] Internal compiler error while calling a pointer to member function that throws
Summary: [6/7 regression] Internal compiler error while calling a pointer to member fu...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 6.1.0
: P3 normal
Target Milestone: 6.2
Assignee: Jakub Jelinek
URL:
Keywords:
: 71553 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-05-13 09:14 UTC by Olivier Goffart
Modified: 2016-07-07 19:07 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-05-13 00:00:00


Attachments
gcc7-pr71100.patch (614 bytes, patch)
2016-05-18 08:59 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Goffart 2016-05-13 09:14:11 UTC
This code crashes GCC 6.1 when optimisations are enabled:

-----------------------------------------------------------
struct Destr
{ ~Destr(); };

struct XX
{
    Destr func() {
        throw "throw";
        return {};
    }
};

inline void call(Destr (XX::*f)(), XX *o)
{
    (o->*f)();
}

void f(XX *o) {
    call(&XX::func, o);
}
-----------------------------------------------------------


Live demo:
http://melpon.org/wandbox/permlink/GyM44dSdEnvqqmZN
Comment 1 Richard Biener 2016-05-13 09:28:28 UTC
Confirmed.

> ./cc1plus  -quiet t.ii -O2
t.ii: In function 'void f(XX*)':
t.ii:14:12: internal compiler error: in assign_temp, at function.c:961
   (o->*f)();
            ^
0xd285c3 assign_temp(tree_node*, int, int)
        /space/rguenther/src/svn/trunk/gcc/function.c:961
0xb50440 expand_call(tree_node*, rtx_def*, int)
        /space/rguenther/src/svn/trunk/gcc/calls.c:2569
0xcccb6c expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
        /space/rguenther/src/svn/trunk/gcc/expr.c:10610
0xcc1633 expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
        /space/rguenther/src/svn/trunk/gcc/expr.c:7962
0xb60525 expand_expr
        /space/rguenther/src/svn/trunk/gcc/expr.h:256
0xb68681 expand_call_stmt
Comment 2 Jakub Jelinek 2016-05-18 08:38:27 UTC
Started with r232167.
Comment 3 Jakub Jelinek 2016-05-18 08:59:22 UTC
Created attachment 38512 [details]
gcc7-pr71100.patch

Untested fix.
Comment 4 Jakub Jelinek 2016-05-18 21:23:38 UTC
Author: jakub
Date: Wed May 18 21:23:07 2016
New Revision: 236430

URL: https://gcc.gnu.org/viewcvs?rev=236430&root=gcc&view=rev
Log:
	PR c++/71100
	* cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Don't drop
	lhs if it has TREE_ADDRESSABLE type.

	* g++.dg/opt/pr71100.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/opt/pr71100.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cgraph.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 Jakub Jelinek 2016-05-18 21:24:48 UTC
Author: jakub
Date: Wed May 18 21:24:16 2016
New Revision: 236431

URL: https://gcc.gnu.org/viewcvs?rev=236431&root=gcc&view=rev
Log:
	PR c++/71100
	* cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Don't drop
	lhs if it has TREE_ADDRESSABLE type.

	* g++.dg/opt/pr71100.C: New test.

Added:
    branches/gcc-6-branch/gcc/testsuite/g++.dg/opt/pr71100.C
Modified:
    branches/gcc-6-branch/gcc/ChangeLog
    branches/gcc-6-branch/gcc/cgraph.c
    branches/gcc-6-branch/gcc/testsuite/ChangeLog
Comment 6 Jakub Jelinek 2016-05-18 21:30:53 UTC
Fixed.
Comment 7 Jakub Jelinek 2016-07-07 19:07:50 UTC
*** Bug 71553 has been marked as a duplicate of this bug. ***