From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3780 invoked by alias); 18 Apr 2011 23:30:06 -0000 Received: (qmail 3729 invoked by uid 22791); 18 Apr 2011 23:30:05 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 18 Apr 2011 23:29:46 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3INTjHm022628 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 18 Apr 2011 19:29:45 -0400 Received: from [127.0.0.1] (ovpn-113-102.phx2.redhat.com [10.3.113.102]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p3INTj7x015467 for ; Mon, 18 Apr 2011 19:29:45 -0400 Message-ID: <4DACC968.6010703@redhat.com> Date: Mon, 18 Apr 2011 23:56:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/48537 (ICE with value-initialization of union with deleted ctor) Content-Type: multipart/mixed; boundary="------------070006090105000009070706" Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-04/txt/msg01471.txt.bz2 This is a multi-part message in MIME format. --------------070006090105000009070706 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 221 The check for UNION_TYPE predates the C++0x extension of unions to allow members with constructors; now we can have a union that needs non-trivial initialization. Tested x86_64-pc-linux-gnu, applying to trunk and 4.6. --------------070006090105000009070706 Content-Type: text/plain; name="48537.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="48537.patch" Content-length: 1180 commit 019dffcf98bb95ebbcb9180d76293b899d674ecf Author: Jason Merrill Date: Mon Apr 18 10:32:55 2011 -0700 PR c++/48537 * init.c (build_value_init): Handle UNION_TYPE the same. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 3280d9b..04d2bb2 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -343,7 +343,7 @@ build_value_init (tree type, tsubst_flags_t complain) NULL, type, LOOKUP_NORMAL, complain), complain); - else if (TREE_CODE (type) != UNION_TYPE && TYPE_NEEDS_CONSTRUCTING (type)) + else if (TYPE_NEEDS_CONSTRUCTING (type)) { /* This is a class that needs constructing, but doesn't have a user-provided constructor. So we need to zero-initialize diff --git a/gcc/testsuite/g++.dg/cpp0x/union4.C b/gcc/testsuite/g++.dg/cpp0x/union4.C new file mode 100644 index 0000000..0705047 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/union4.C @@ -0,0 +1,17 @@ +// PR c++/48537 +// { dg-options -std=c++0x } + +struct SFoo +{ + SFoo() =delete; // { dg-error "declared" } +}; + +union UFoo // { dg-error "deleted" } +{ + SFoo foo; +}; + +int main() +{ + UFoo(); // { dg-error "deleted" } +} --------------070006090105000009070706--