[Bug c++/94619] String literals as non-type template parameter fails to compile with partial specialization of calling function

2021-08-04 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94619

Andrew Pinski  changed:

   What|Removed |Added

  Known to work||10.3.0, 11.1.0
  Known to fail||10.2.0

--- Comment #3 from Andrew Pinski  ---
Seems to be fixed in GCC 10.3.0 and 11+.

[Bug c++/94619] String literals as non-type template parameter fails to compile with partial specialization of calling function

2020-08-25 Thread samestimable2016 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94619

Sam Huang  changed:

   What|Removed |Added

 CC||samestimable2016 at gmail dot 
com

--- Comment #2 from Sam Huang  ---
I was going to file the same bug but with a different and much simpler
scenario. The compiler fails to deduce the parameter when you pass a non-type
template parameter to another template.

Consider the following scenario (tested on compiler explorer using GCC 9.1,
9.2, 9.3, 10.1, 10.2 with options -std=c++2a -O3):

>>>

#include 
#include 

template
struct constexpr_string
{
std::array _data;

public:
constexpr constexpr_string(const char ()[N])
{
std::copy(std::begin(data), std::end(data), _data.data());
}
};

template
struct foo
{};

template
struct bar
{
using type = foo; // <-- Fails to compile on this line
};

int main()
{}

>>>

The diagnostic produced by the compiler is:
"
:23:28: error: class template argument deduction failed:

   23 | using type = foo; // <-- Fails to compile on this line

  |^

:23:28: error: no matching function for call to
'constexpr_string(constexpr_string<...auto...>)'

:10:15: note: candidate: 'template
constexpr_string(const char (&)[N])-> constexpr_string'

   10 | constexpr constexpr_string(const char ()[N])

  |   ^~~~

:10:15: note:   template argument deduction/substitution failed:

:23:28: note:   mismatched types 'const char [N]' and
'constexpr_string<...auto...>'

   23 | using type = foo; // <-- Fails to compile on this line

  |^

:5:8: note: candidate: 'template
constexpr_string(constexpr_string)-> constexpr_string'

5 | struct constexpr_string

  |^~~~

:5:8: note:   template argument deduction/substitution failed:

:23:28: note:   mismatched types 'constexpr_string' and
'constexpr_string<...auto...>'

   23 | using type = foo; // <-- Fails to compile on this line

  |^

ASM generation compiler returned: 1

:23:28: error: class template argument deduction failed:

   23 | using type = foo; // <-- Fails to compile on this line

  |^

:23:28: error: no matching function for call to
'constexpr_string(constexpr_string<...auto...>)'

:10:15: note: candidate: 'template
constexpr_string(const char (&)[N])-> constexpr_string'

   10 | constexpr constexpr_string(const char ()[N])

  |   ^~~~

:10:15: note:   template argument deduction/substitution failed:

:23:28: note:   mismatched types 'const char [N]' and
'constexpr_string<...auto...>'

   23 | using type = foo; // <-- Fails to compile on this line

  |^

:5:8: note: candidate: 'template
constexpr_string(constexpr_string)-> constexpr_string'

5 | struct constexpr_string

  |^~~~

:5:8: note:   template argument deduction/substitution failed:

:23:28: note:   mismatched types 'constexpr_string' and
'constexpr_string<...auto...>'

   23 | using type = foo; // <-- Fails to compile on this line

  |^

Execution build compiler returned: 1
"

[Bug c++/94619] String literals as non-type template parameter fails to compile with partial specialization of calling function

2020-04-16 Thread daniel.kruegler at googlemail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94619

Daniel Krügler  changed:

   What|Removed |Added

 CC||daniel.kruegler@googlemail.
   ||com

--- Comment #1 from Daniel Krügler  ---
The non-void return expression in the void bar function makes the example
ill-formed regardless of the other problem, so let's fix that first:

>>
template  struct A {
char str [length];

constexpr A(char const () [length]) {
for (unsigned i = 0; i < length; ++i)
str[i] = s[i];
}
};

template  struct B {
auto bar() const {
return a.str;
}
};

//template  void fu (Tconst& t) // Compiles successfully
  template  void fu (B const& t) // Does not compile
//template  void fu (B> const& t) // Does not compile either
{
  t.bar();
}

void test() {
B<":/"> m;
fu(m);
}
>>