This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch c++]: Fix for PR/65390
- From: Kai Tietz <ktietz70 at googlemail dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 20 Mar 2015 15:53:42 +0100
- Subject: Re: [patch c++]: Fix for PR/65390
- Authentication-results: sourceware.org; auth=none
- References: <CAEwic4aBYYmNx3CA6uuhsVe7LnSTqP2gnGJvM9y8k=NYEOaDgg at mail dot gmail dot com> <55071BD5 dot 9020909 at redhat dot com> <CAEwic4ZHKL6X-NfWoamWCLLxCT==PNU_+C4vR=srFDUduGW85w at mail dot gmail dot com> <55081FBB dot 2050903 at redhat dot com> <CAEwic4ZGs5rP6MRQucDiuu31g6_iXHZK3nVBbCzL=yPqh5nhiw at mail dot gmail dot com>
Hello,
the problem here is that for cases of vla-array-types, the types don't
get finally layouted in build_cplus_array_type. So the type-alignment
isn't set in such cases for the resulting type.
ChangeLog
2015-03-20 Kai Tietz <ktietz@redhat.com>
PR c++/65390
* tree.c (strip_typedefs): Ignore alignment
difference during processing template.
2015-03-20 Kai Tietz <ktietz@redhat.com>
PR c++/65390
* g++.dg/template/pr65390.C: New file.
Tested on x86_64-unknown-linux-gnu. Ok for apply?
Regards,
Kai
Index: gcc/gcc/cp/tree.c
===================================================================
--- gcc.orig/gcc/cp/tree.c
+++ gcc/gcc/cp/tree.c
@@ -1356,7 +1356,8 @@ strip_typedefs (tree t)
if (!result)
result = TYPE_MAIN_VARIANT (t);
if (TYPE_USER_ALIGN (t) != TYPE_USER_ALIGN (result)
- || TYPE_ALIGN (t) != TYPE_ALIGN (result))
+ || (processing_template_decl
+ && TYPE_ALIGN (t) != TYPE_ALIGN (result)))
{
gcc_assert (TYPE_USER_ALIGN (t));
if (TYPE_ALIGN (t) == TYPE_ALIGN (result))
Index: gcc/gcc/testsuite/g++.dg/template/pr65390.C
===================================================================
--- /dev/null
+++ gcc/gcc/testsuite/g++.dg/template/pr65390.C
@@ -0,0 +1,12 @@
+// { dg-do compile }
+// { dg-options "-Wno-vla" }
+template<typename T> struct shared_ptr { };
+
+template<typename T, typename Arg>
+shared_ptr<T> make_shared(Arg) { return shared_ptr<T>(); } // {
dg-message "note" }
+// { dg-warning "ignoring attributes" "template" { target *-*-* } 6 }
+
+void f(int n){
+ make_shared<int[n]>(1); // { dg-error "no matching" }
+}
+// { dg-error "variably modified type|trying to instantiate" "type" {
target *-*-* } 10 }