Bug 21440 - [4.0/4.1 Regression] ICE with statement-as-expression
Summary: [4.0/4.1 Regression] ICE with statement-as-expression
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.2
Assignee: Mark Mitchell
URL:
Keywords: ice-on-valid-code, monitored
: 23636 (view as bug list)
Depends on: 20103
Blocks:
  Show dependency treegraph
 
Reported: 2005-05-07 08:26 UTC by dank
Modified: 2005-09-06 15:15 UTC (History)
3 users (show)

See Also:
Host: i686-linux
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-06-02 10:01:30


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dank 2005-05-07 08:26:49 UTC
The following test program works with gcc-2.95.3 and gcc-3.4.1,
but aborts with this error on gcc-4.0.0:

z.ii: In function 'void bar()':
z.ii:11: internal compiler error: in create_tmp_var, at gimplify.c:368


struct Foo {
  ~Foo() {}
  int i;
  operator bool() { return !i; }
};

void bar() {
    Foo foo = ({
        Foo bletch;
        bletch.i = 0;
        bletch;
    });
}

This popped up in an early run of gcc-4.0.0 on real code.
Comment 1 dank 2005-05-07 08:31:13 UTC
Forgot to mention: I have applied the fixes for
PR20973 and PR21173 as given in bugzilla.

Comment 2 Andrew Pinski 2005-05-07 15:02:23 UTC
Confirmed. Related to PR 20103.
Comment 3 Andrew Pinski 2005-05-09 20:43:55 UTC
This has been failing since the tree-ssa branch was merged in and on the tree-ssa since at least
2003-05-30.
Comment 4 Nathan Sidwell 2005-06-02 11:41:19 UTC
ug, this is horrible.  we're incorrectly smashing up the inside of a STMT_EXPR
to pull out a TARGET_EXPR we know is there.  Unfortunately that moves a decl
outside of its cleanup.  We really should be going the other way and pushing the
user of the STMT_EXPR into it.  I suspect we'll need to move further along the
path of making STMT_EXPRs look like real function calls, complete with an
explicitly generated RESULT_DECL.
Comment 5 Mark Mitchell 2005-07-06 17:02:40 UTC
Postponed until 4.0.2.
Comment 6 Volker Reichelt 2005-07-25 11:57:59 UTC
Shorter testcase:

===========================
struct A
{
    ~A();
};

void foo()
{
    A a = ({ A b; b; });
}
===========================
Comment 7 GCC Commits 2005-09-05 15:59:40 UTC
Subject: Bug 21440

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2005-09-05 15:59:32

Modified files:
	gcc/cp         : semantics.c ChangeLog 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/ext: stmtexpr5.C stmtexpr6.C 

Log message:
	PR c++/21440
	* semantics.c (finish_stmt_expr_expr): Add an explicit
	initialization to the last statement in the statement-expression.
	* (finish_stmt_expr): Adjust accordingly.
	
	PR c++/21440
	* g++.dg/ext/stmtexpr5.C: New test.
	* g++.dg/ext/stmtexpr6.C: Likewise.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/semantics.c.diff?cvsroot=gcc&r1=1.484&r2=1.485
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4869&r2=1.4870
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6009&r2=1.6010
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/stmtexpr5.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/stmtexpr6.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 8 GCC Commits 2005-09-05 16:00:52 UTC
Subject: Bug 21440

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	mmitchel@gcc.gnu.org	2005-09-05 16:00:46

Modified files:
	gcc/cp         : semantics.c ChangeLog 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/ext: stmtexpr5.C stmtexpr6.C 

Log message:
	PR c++/21440
	* semantics.c (finish_stmt_expr_expr): Add an explicit
	initialization to the last statement in the statement-expression.
	* (finish_stmt_expr): Adjust accordingly.
	
	PR c++/21440
	* g++.dg/ext/stmtexpr5.C: New test.
	* g++.dg/ext/stmtexpr6.C: Likewise.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/semantics.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.463.2.7&r2=1.463.2.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.89&r2=1.4648.2.90
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.376&r2=1.5084.2.377
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/stmtexpr5.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/stmtexpr6.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1

Comment 9 Mark Mitchell 2005-09-05 16:08:24 UTC
Fixed in 4.0.2.
Comment 10 Mark Mitchell 2005-09-06 15:15:42 UTC
*** Bug 23636 has been marked as a duplicate of this bug. ***