https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113110
Bug ID: 113110 Summary: GCC rejects call to more specialized const char array version with string literal Product: gcc Version: 13.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jlame646 at gmail dot com Target Milestone: --- GCC seems to rejects valid code. The following code is rejected by gcc and clang while accepted by msvc. As the first version is more specialized for const char arrays, it seems the first version should be used. https://godbolt.org/z/anEnY44Te ``` #include <cstring> using namespace std; // fist version template <size_t N, size_t M> int compare(const char (&a)[N], const char (&b)[M]) { return strcmp(a, b); } // second version template <typename T> int compare(const T &a, const T &b) { if (a < b) return -1; if (b < a) return 1; return 0; } int main() { compare("dog", "cat"); //gcc and clang rejects while msvc accepts } ```