Bug 89974 - ICE on a definition of a non-type specialization on a struct object with pointer to member function
Summary: ICE on a definition of a non-type specialization on a struct object with poin...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: 9.0
Assignee: Martin Sebor
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2019-04-04 17:27 UTC by Martin Sebor
Modified: 2019-04-04 23:15 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2019-04-04 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Sebor 2019-04-04 17:27:34 UTC
The following C++ 2a program causes an ICE.  An equivalent program using a pointer to member data compiles successfully.  I came across this while testing my patch for pr47488, pr89833, and pr89876.

$ cat z.C && gcc -c -O2 -Wall -Wextra -std=c++2a z.C
struct A { void (A::*p)(); };
template <A> struct X { };
X<A{ 0 }> x;

z.C:3:9: internal compiler error: canonical types differ for identical types ‘void (A::*)()’ and ‘void (A::*)()’
    3 | X<A{ 0 }> x;
      |         ^
0xb7ba72 comptypes(tree_node*, tree_node*, int)
	/src/gcc/git-svn/gcc/cp/typeck.c:1479
0x9b0829 find_substitution
	/src/gcc/git-svn/gcc/cp/mangle.c:692
0x9b8840 write_type
	/src/gcc/git-svn/gcc/cp/mangle.c:2054
0x9c10a7 write_template_arg_literal
	/src/gcc/git-svn/gcc/cp/mangle.c:3357
0x9bd561 write_expression
	/src/gcc/git-svn/gcc/cp/mangle.c:2890
0x9bfdcd write_expression
	/src/gcc/git-svn/gcc/cp/mangle.c:3150
0x9bfdcd write_expression
	/src/gcc/git-svn/gcc/cp/mangle.c:3150
0x9c572f mangle_template_parm_object(tree_node*)
	/src/gcc/git-svn/gcc/cp/mangle.c:4267
0xa8c265 get_template_parm_object
	/src/gcc/git-svn/gcc/cp/pt.c:6702
0xa8e048 convert_nontype_argument
	/src/gcc/git-svn/gcc/cp/pt.c:7160
0xa91795 convert_template_argument
	/src/gcc/git-svn/gcc/cp/pt.c:8070
0xa93370 coerce_template_parms
	/src/gcc/git-svn/gcc/cp/pt.c:8547
0xa93a65 coerce_innermost_template_parms
	/src/gcc/git-svn/gcc/cp/pt.c:8666
0xa96177 lookup_template_class_1
	/src/gcc/git-svn/gcc/cp/pt.c:9357
0xa9885d lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*, int, int)
	/src/gcc/git-svn/gcc/cp/pt.c:9716
0xb240c0 finish_template_type(tree_node*, tree_node*, int)
	/src/gcc/git-svn/gcc/cp/semantics.c:3312
0xa223e1 cp_parser_template_id
	/src/gcc/git-svn/gcc/cp/parser.c:16479
0xa2f9be cp_parser_class_name
	/src/gcc/git-svn/gcc/cp/parser.c:23274
0xa0d6d7 cp_parser_qualifying_entity
	/src/gcc/git-svn/gcc/cp/parser.c:6693
0xa0c6cd cp_parser_nested_name_specifier_opt
	/src/gcc/git-svn/gcc/cp/parser.c:6379
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Comment 1 Martin Sebor 2019-04-04 23:10:54 UTC
Author: msebor
Date: Thu Apr  4 23:10:23 2019
New Revision: 270155

URL: https://gcc.gnu.org/viewcvs?rev=270155&root=gcc&view=rev
Log:
PR c++/89974 - ICE on a definition of a non-type specialization on a struct object with pointer to member function
PR c++/89878 - same specializations on a zero-initialized struct object as a non-type parameter treated as distinct
PR c++/89833 - sorry, unimplemented: string literal in function template signature
PR c++/47488 - sorry, unimplemented: string literal in function template signature

gcc/cp/ChangeLog:

	PR c++/89974
	PR c++/89878
	PR c++/89833
	PR c++/47488
	* decl.c (reshape_init_array_1): Strip trailing zero-initializers
	from arrays of trivial type and known size.
	* mangle.c (write_expression): Convert braced initializer lists
	to STRING_CSTs.
	(write_expression): Trim trailing zero-initializers from arrays
	of trivial type.
	(write_template_arg_literal): Mangle strings the same as braced
	initializer lists.

gcc/testsuite/ChangeLog:

	PR c++/89974
	PR c++/89878
	PR c++/89833
	PR c++/47488
	* gcc/testsuite/g++.dg/abi/mangle69.C: New test.
	* gcc/testsuite/g++.dg/abi/mangle70.C: New test.
	* gcc/testsuite/g++.dg/abi/mangle71.C: New test.
	* gcc/testsuite/g++.dg/abi/mangle72.C: New test.
	* gcc/testsuite/g++.dg/cpp0x/constexpr-array19.C: New test.
	* gcc/testsuite/g++.dg/cpp2a/nontype-class15.C: New test.
	* gcc/testsuite/g++.dg/cpp2a/nontype-class16.C: New test.
	* gcc/testsuite/g++.dg/init/array51.C: New test.


Added:
    trunk/gcc/testsuite/g++.dg/abi/mangle69.C
    trunk/gcc/testsuite/g++.dg/abi/mangle70.C
    trunk/gcc/testsuite/g++.dg/abi/mangle71.C
    trunk/gcc/testsuite/g++.dg/abi/mangle72.C
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-array19.C
    trunk/gcc/testsuite/g++.dg/cpp2a/nontype-class15.C
    trunk/gcc/testsuite/g++.dg/cpp2a/nontype-class16.C
    trunk/gcc/testsuite/g++.dg/init/array51.C
    trunk/gcc/testsuite/g++.dg/template/nontype29.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/mangle.c
    trunk/gcc/testsuite/ChangeLog
Comment 2 Martin Sebor 2019-04-04 23:15:11 UTC
Fixed via r270155.