From: Jason Merrill Date: Sat, 15 Dec 2012 04:02:52 +0000 (-0500) Subject: re PR c++/55685 (ICE: canonical types differ for identical types) X-Git-Tag: releases/gcc-4.8.0~1368 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1c9597213362d8fc5fe58016a5790bd331c1c997;p=thirdparty%2Fgcc.git re PR c++/55685 (ICE: canonical types differ for identical types) PR c++/55685 * pt.c (tsubst_copy_and_build): Don't use SIZEOF_EXPR_TYPE_P in templates. From-SVN: r194517 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ee9bf7749efd..83d3c63860ce 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2012-12-14 Jason Merrill + PR c++/55685 + * pt.c (tsubst_copy_and_build): Don't use SIZEOF_EXPR_TYPE_P in + templates. + PR c++/42315 * decl.c (maybe_deduce_size_from_array_init): Don't change the variable type. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 91450d854070..a21522b35106 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13563,7 +13563,7 @@ tsubst_copy_and_build (tree t, { if (TREE_CODE (r) != SIZEOF_EXPR || TYPE_P (op1)) { - if (TYPE_P (op1)) + if (!processing_template_decl && TYPE_P (op1)) { r = build_min (SIZEOF_EXPR, size_type_node, build1 (NOP_EXPR, op1, error_mark_node)); diff --git a/gcc/testsuite/g++.dg/template/sizeof15.C b/gcc/testsuite/g++.dg/template/sizeof15.C new file mode 100644 index 000000000000..3298dad3f94d --- /dev/null +++ b/gcc/testsuite/g++.dg/template/sizeof15.C @@ -0,0 +1,13 @@ +// PR c++/55685 + +typedef __SIZE_TYPE__ size_t; +template +struct A; + +template struct B +{ + static A x; +}; + +template +A B ::x;