From: Jason Merrill Date: Mon, 18 Apr 2011 22:40:43 +0000 (-0400) Subject: re PR c++/48537 (C++0x: ICE using union with non-trivial member) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=09262fffd58c8bb1f474aa64c4120967f38d3d00;p=gcc.git re PR c++/48537 (C++0x: ICE using union with non-trivial member) PR c++/48537 * init.c (build_value_init): Handle UNION_TYPE the same. From-SVN: r172678 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e7d75e881fe..cf21fd64a55 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2011-04-18 Jason Merrill + + PR c++/48537 + * init.c (build_value_init): Handle UNION_TYPE the same. + 2011-04-18 Jakub Jelinek PR c++/48632 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 3280d9b5d0d..04d2bb2ab2f 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/ChangeLog b/gcc/testsuite/ChangeLog index 96fb5c5ace8..b8e89094452 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-04-18 Jason Merrill + + * g++.dg/cpp0x/union4.C: New. + 2011-04-18 Jakub Jelinek PR middle-end/48661 diff --git a/gcc/testsuite/g++.dg/cpp0x/union4.C b/gcc/testsuite/g++.dg/cpp0x/union4.C new file mode 100644 index 00000000000..07050475d36 --- /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" } +}