https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121518

            Bug ID: 121518
           Summary: Deducing member array type from string literal
           Product: gcc
           Version: 15.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nedimsehic50 at gmail dot com
  Target Milestone: ---

Attempting to compile the following code we get an error shown in the comment:

#include <cstddef>

template <std::size_t N>
struct S {
    char str[N]{};
};

int main() {
    S s0{"a"};  // OK
    S s1("a");  // error: class template argument deduction failed
                // note:   mismatched types 'S<N>' and 'const char*'
}

Deduction here should be possible. According to this defect report
(https://cplusplus.github.io/CWG/issues/2681.html), there should be an
appropriate deduction guide which takes an lvalue reference to the
const-qualified type of `str` which is `const char (&)[N]`, but it seems like
that doesn't happen here.

Reply via email to