https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96115
Bug ID: 96115
Summary: Char literal, decays to a pointer when passed to
function pointer
Product: gcc
Version: 10.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: boris_oncev at hotmail dot com
Target Milestone: ---
Example code:
struct SL{
template <int N>
SL(const char (&Str)[N]) {}
};
int foo(SL x) {
return 2;
}
int main() {
int (*f)(SL) = &foo;
foo("asd"); // works fine
f("asd"); // error could not convert '(const char*) to SL
}
Godbot link:
https://godbolt.org/z/vo8lOf
works on other compilers clang, msvc and icc