public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "aoliva at redhat dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/20103] [4.0/4.1 regression] ICE in create_tmp_var with C99 style struct initializer Date: Sun, 06 Mar 2005 07:30:00 -0000 [thread overview] Message-ID: <20050306072938.13727.qmail@sourceware.org> (raw) In-Reply-To: <20050220111234.20103.falk@debian.org> ------- Additional Comments From aoliva at gcc dot gnu dot org 2005-03-06 07:29 ------- Subject: Re: [PR c++/20103] failure to gimplify constructors for addressable types On Mar 5, 2005, Mark Mitchell <mark@codesourcery.com> wrote: > Alexandre Oliva wrote: >> Testing now. I was a bit surprised that the casts to (const B&) >> weren't reported as faulty, but didn't check the standard on it. > I'd have to check the rules -- but I'm sure it's not a problem with > your patch. Either its correct, or an already-present bug. >> Ok >> to install if testing passes? > Yes. Unfortunately, g++.dg/template/ctor1.C and g++.dg/template/complit1.C regressed. As it turned out, complit1.C was in error, and had to be adjusted to match g++.dg/ext/complit1.C, since the only significant difference between them was that one of them had the compound-literal within a ctor of a template class. ctor1.C, however, exposed a failure to handle TARGET_EXPRs while instantiating templates. So I extended the tsubst machinery to do it, and now ctor1.C passes again. I also noticed that the patch fixes g++.old-deja/g++.oliva/expr2.C, yay! Here's the latest version of the patch, that so far passed make -C gcc all check-g++. Full bootstrap and regtest on x86_64-linux-gnu still pending. Ok to install if it passes? Index: gcc/cp/ChangeLog from Alexandre Oliva <aoliva@redhat.com> PR c++/20103 * semantics.c (finish_compound_literal): Wrap it in a target_expr. * pt.c (tsubst_copy_and_build): Handle TARGET_EXPR. Index: gcc/cp/semantics.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v retrieving revision 1.463 diff -u -p -r1.463 semantics.c --- gcc/cp/semantics.c 23 Feb 2005 05:30:48 -0000 1.463 +++ gcc/cp/semantics.c 6 Mar 2005 07:12:11 -0000 @@ -1996,7 +1996,9 @@ finish_compound_literal (tree type, tree complete_array_type (type, compound_literal, 1); } - return compound_literal; + /* A compound-literal is an lvalue in C, but is it going to be + in ISO C++? Assume it's an rvalue for now. */ + return get_target_expr (compound_literal); } /* Return the declaration for the function-name variable indicated by Index: gcc/cp/pt.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v retrieving revision 1.978 diff -u -p -r1.978 pt.c --- gcc/cp/pt.c 21 Feb 2005 23:12:26 -0000 1.978 +++ gcc/cp/pt.c 6 Mar 2005 07:12:19 -0000 @@ -8744,6 +8744,26 @@ tsubst_copy_and_build (tree t, return build_throw (RECUR (TREE_OPERAND (t, 0))); + case TARGET_EXPR: + { + tree r = tsubst_copy (t, args, complain, in_decl); + + TREE_TYPE (r) = RECUR (TREE_TYPE (t)); + TARGET_EXPR_SLOT (r) = RECUR (TARGET_EXPR_SLOT (t)); + TARGET_EXPR_INITIAL (r) = RECUR (TARGET_EXPR_INITIAL (t)); + TARGET_EXPR_CLEANUP (r) = RECUR (TARGET_EXPR_CLEANUP (t)); + + if (TREE_TYPE (TARGET_EXPR_SLOT (t)) + == TREE_TYPE (TARGET_EXPR_INITIAL (t))) + TREE_TYPE (TARGET_EXPR_SLOT (r)) = + TREE_TYPE (TARGET_EXPR_INITIAL (r)); + + if (TREE_TYPE (t) == TREE_TYPE (TARGET_EXPR_SLOT (t))) + TREE_TYPE (r) = TREE_TYPE (TARGET_EXPR_SLOT (r)); + + return r; + } + case CONSTRUCTOR: { tree r; Index: gcc/testsuite/ChangeLog from Alexandre Oliva <aoliva@redhat.com> PR c++/20103 * g++.dg/tree-ssa/pr20103.C: New. * g++.dg/template/complit1.C: Expect error like ext/complit1.C. Index: gcc/testsuite/g++.dg/tree-ssa/pr20103.C =================================================================== RCS file: gcc/testsuite/g++.dg/tree-ssa/pr20103.C diff -N gcc/testsuite/g++.dg/tree-ssa/pr20103.C --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gcc/testsuite/g++.dg/tree-ssa/pr20103.C 6 Mar 2005 07:12:35 -0000 @@ -0,0 +1,59 @@ +// PR c++/20103 + +// { dg-do compile } + +// { dg-options "" } + +// Gimplification used to fail for (B){x}, because create_tmp_var +// required a non-addressable type, and we didn't wrap the constructor +// in a target_expr, ensuring it's moved to a separate decl. + +// Whether it is an lvalue, like in C, or an rvalue, is up to the ISO +// C++ Commitete to decide in the second version of the C++ Standard. +// We're going with rvalues for now. + +struct A +{ + A(const A&); +}; + +struct B +{ + A a; +}; + +void foo(B); +void bar(B&); // { dg-error "in passing argument" } +void bac(const B&); +void bap(const B*); + +void baz(A &x) +{ + foo ((B){x}); + bar ((B){x}); // { dg-error "non-const reference" } + bac ((B){x}); + bap (&(B){x}); // { dg-error "address of temporary" } + + foo ((const B&)(B){x}); + bar ((B&)(B){x}); // { dg-error "invalid cast" } + bac ((const B&)(B){x}); + bap (&(const B&)(B){x}); +} + +template <typename T, typename U> +void baz(T &x) +{ + foo ((U){x}); + bar ((U){x}); // { dg-error "non-const reference" } + bac ((U){x}); + bap (&(U){x}); // { dg-error "address of temporary" } + + foo ((const U&)(U){x}); + bar ((U&)(U){x}); // { dg-error "invalid cast" } + bac ((const U&)(U){x}); + bap (&(const U&)(U){x}); +} + +void bazT(A &x) { + baz<A,B>(x); +} Index: gcc/testsuite/g++.dg/template/complit1.C =================================================================== RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/template/complit1.C,v retrieving revision 1.3 diff -u -p -r1.3 complit1.C --- gcc/testsuite/g++.dg/template/complit1.C 28 Dec 2002 07:48:08 -0000 1.3 +++ gcc/testsuite/g++.dg/template/complit1.C 6 Mar 2005 07:12:35 -0000 @@ -6,6 +6,6 @@ template <int D> struct C { }; template<int D> -C<D>::C() : d((int[]){1,2,3}) {} +C<D>::C() : d((int[]){1,2,3}) {} // { dg-error "assignment of arrays" } -template class C<1>; +template class C<1>; // { dg-error "instantiated from" } Index: gcc/testsuite/g++.old-deja/g++.oliva/ChangeLog from Alexandre Oliva <aoliva@redhat.com> PR c++/20103 * expr2.C: Fixed. Index: gcc/testsuite/g++.old-deja/g++.oliva/expr2.C =================================================================== RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.old-deja/g++.oliva/expr2.C,v retrieving revision 1.5 diff -u -p -r1.5 expr2.C --- gcc/testsuite/g++.old-deja/g++.oliva/expr2.C 1 May 2003 02:02:47 -0000 1.5 +++ gcc/testsuite/g++.old-deja/g++.oliva/expr2.C 6 Mar 2005 07:12:35 -0000 @@ -1,4 +1,4 @@ -// { dg-do run { xfail *-*-* } } +// { dg-do run } // Copyright (C) 2000 Free Software Foundation -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20103
next prev parent reply other threads:[~2005-03-06 7:30 UTC|newest] Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top 2005-02-20 17:37 [Bug c++/20103] New: [4.0 regression] ICE in create_tmp_var falk at debian dot org 2005-02-20 17:52 ` [Bug c++/20103] " falk at debian dot org 2005-02-20 19:02 ` pinskia at gcc dot gnu dot org 2005-02-20 19:25 ` pinskia at gcc dot gnu dot org 2005-02-20 19:27 ` pinskia at gcc dot gnu dot org 2005-02-21 21:49 ` pinskia at gcc dot gnu dot org 2005-02-23 11:10 ` [Bug c++/20103] [4.0 regression] ICE in create_tmp_var with C99 style struct initializer pinskia at gcc dot gnu dot org 2005-03-02 13:48 ` [Bug c++/20103] [4.0/4.1 " reichelt at gcc dot gnu dot org 2005-03-03 7:01 ` aoliva at gcc dot gnu dot org 2005-03-03 7:42 ` aoliva at redhat dot com 2005-03-04 23:22 ` aoliva at redhat dot com 2005-03-04 23:30 ` mark at codesourcery dot com 2005-03-05 11:41 ` giovannibajo at libero dot it 2005-03-05 12:16 ` joseph at codesourcery dot com 2005-03-05 13:37 ` aoliva at redhat dot com 2005-03-05 14:03 ` aoliva at redhat dot com 2005-03-05 21:47 ` mark at codesourcery dot com 2005-03-06 7:30 ` aoliva at redhat dot com [this message] 2005-03-06 18:02 ` mark at codesourcery dot com 2005-03-07 3:26 ` aoliva at redhat dot com 2005-03-07 4:44 ` mark at codesourcery dot com 2005-03-07 8:51 ` giovannibajo at libero dot it 2005-03-07 14:44 ` aoliva at redhat dot com 2005-03-07 16:05 ` mark at codesourcery dot com 2005-03-07 17:05 ` aoliva at redhat dot com 2005-03-07 18:05 ` mark at codesourcery dot com 2005-03-07 21:58 ` aoliva at redhat dot com 2005-03-07 22:39 ` mark at codesourcery dot com 2005-03-08 7:25 ` aoliva at redhat dot com 2005-03-08 7:46 ` mark at codesourcery dot com 2005-03-08 20:44 ` aoliva at redhat dot com 2005-03-08 21:55 ` aoliva at redhat dot com 2005-03-11 15:20 ` rth at gcc dot gnu dot org 2005-03-11 19:29 ` aoliva at redhat dot com 2005-03-17 10:42 ` aoliva at redhat dot com 2005-03-17 11:49 ` rth at gcc dot gnu dot org 2005-03-18 5:39 ` aoliva at redhat dot com 2005-03-18 10:16 ` aoliva at redhat dot com 2005-04-02 17:27 ` aoliva at redhat dot com 2005-04-05 14:47 ` pinskia at gcc dot gnu dot org 2005-04-17 3:57 ` mmitchel at gcc dot gnu dot org 2005-04-17 3:59 ` aoliva at redhat dot com 2005-04-17 4:03 ` mark at codesourcery dot com 2005-04-17 6:25 ` aoliva at redhat dot com 2005-07-06 17:03 ` mmitchel at gcc dot gnu dot org 2005-07-22 21:12 ` steven at gcc dot gnu dot org 2005-09-27 16:18 ` mmitchel at gcc dot gnu dot org [not found] <bug-20103-2744@http.gcc.gnu.org/bugzilla/> 2005-10-13 20:06 ` pinskia at gcc dot gnu dot org 2005-10-14 14:37 ` pinskia at gcc dot gnu dot org 2005-10-31 2:44 ` mmitchel at gcc dot gnu dot org 2006-05-25 20:26 ` mmitchel at gcc dot gnu dot org 2006-06-09 9:57 ` jakub at gcc dot gnu dot org 2006-06-10 22:23 ` pinskia at gcc dot gnu dot org 2006-07-03 23:52 ` tbm at cyrius dot com 2007-02-14 9:05 ` mmitchel at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20050306072938.13727.qmail@sourceware.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).