From: Jason Merrill Date: Fri, 19 Jul 2019 08:52:58 +0000 (-0400) Subject: PR c++/85552 - wrong instantiation of dtor for DMI. X-Git-Tag: releases/gcc-9.2.0~132 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=760811e5f54e5052059f4697648c5a13008108c4;p=thirdparty%2Fgcc.git PR c++/85552 - wrong instantiation of dtor for DMI. * typeck2.c (digest_nsdmi_init): Set tf_no_cleanup for direct-init. From-SVN: r273596 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 71bddd7d40d0..4b69396e7307 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-07-19 Jason Merrill + + PR c++/85552 - wrong instantiation of dtor for DMI. + * typeck2.c (digest_nsdmi_init): Set tf_no_cleanup for direct-init. + 2019-07-19 Nina Dinka Ranns PR c++/63149 - Wrong auto deduction from braced-init-list. diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index df002a1664c7..bdb98f844350 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1293,7 +1293,10 @@ digest_nsdmi_init (tree decl, tree init, tsubst_flags_t complain) tree type = TREE_TYPE (decl); int flags = LOOKUP_IMPLICIT; if (DIRECT_LIST_INIT_P (init)) - flags = LOOKUP_NORMAL; + { + flags = LOOKUP_NORMAL; + complain |= tf_no_cleanup; + } if (BRACE_ENCLOSED_INITIALIZER_P (init) && CP_AGGREGATE_TYPE_P (type)) init = reshape_init (type, init, complain); diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-list5.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-list5.C new file mode 100644 index 000000000000..a12740b23b04 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-list5.C @@ -0,0 +1,30 @@ +// PR c++/85552 +// { dg-do compile { target c++11 } } + +template +struct uptr { + uptr() { } + uptr(void*) { } + ~uptr() { static_assert(sizeof(T), "complete type"); } +}; + +class S; + +class Compiles +{ + uptr s; +}; + +class DoesntCompile +{ + ~DoesntCompile(); + DoesntCompile(); + + uptr s1 { }; + uptr s2 { nullptr }; +}; + +int main() +{ + return 0; +}