Bug 89833 - [9 Regression] sorry, unimplemented: string literal in function template signature
Summary: [9 Regression] sorry, unimplemented: string literal in function template sign...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 9.0
: P1 normal
Target Milestone: 9.0
Assignee: Martin Sebor
URL:
Keywords: FIXME, patch, rejects-valid
Depends on:
Blocks:
 
Reported: 2019-03-26 18:09 UTC by Jonathan Wakely
Modified: 2019-04-04 23:11 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2019-03-26 18:09:58 UTC
When compiled with -std=c++2a this started to fail with r269814:

using size_t = decltype(sizeof(0));
template<typename T, size_t N> struct array { T data[N]; };
template<size_t...> struct index_sequence { };
template<size_t> struct make_index_sequence;
template<> struct make_index_sequence<6> : index_sequence<0, 1, 2, 3, 4, 5> { };

template <size_t N>
struct mystring : array<char, N> {
    template <size_t ...Idx>
    constexpr mystring(const char (&str)[N], index_sequence<Idx...>)
    : array<char, N>{str[Idx]...} {}

    constexpr mystring(const char (&str)[N]) : mystring(str, make_index_sequence<N>{}) {}
};

template <size_t N>
mystring(const char (&str)[N]) -> mystring<N>;

template <mystring>
struct S {};

S<"Hello"> s;


reg.cc: In instantiation of ‘struct S<mystring<6>{array<char, 6>{"Hello"}}>’:
reg.cc:24:12:   required from here
reg.cc:22:10: sorry, unimplemented: string literal in function template signature
   22 | struct S {};
      |          ^
reg.cc:22:10: sorry, unimplemented: string literal in function template signature
reg.cc:22:10: sorry, unimplemented: string literal in function template signature
Comment 1 Marek Polacek 2019-03-26 18:12:20 UTC
Right:
https://gcc.gnu.org/ml/gcc-patches/2019-03/msg01064.html
Comment 2 Jonathan Wakely 2019-03-27 08:50:33 UTC
N.B. I think this is only a regression against recent trunk. It's a new C++2a feature which isn't supported in any released version.
Comment 3 Martin Sebor 2019-04-03 15:13:21 UTC
Patch: https://gcc.gnu.org/ml/gcc-patches/2019-04/msg00000.html
Comment 4 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 5 Martin Sebor 2019-04-04 23:11:30 UTC
Fixed in r270155.