You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
structT {
template<int N>
T(constchar(&)[N]) {}
};
structS {
S(constchar(&)[5]) {}
};
T t({"awoo"}); // error: initializer-string for char array is too long
S s({"awoo"}); // OK
There is a surprising and likely unintentional inconsistency here. Implementations diverge on whether the initialization of t is valid.
While [dcl.init.string] generally allows initialization of character arrays with a string-literal that is surrounded by braces, [temp.deduct.call] paragraph 1 states that N is deduced to the length of the initializer list, which is 1, resulting in a failed attempt at initializing const char(&)[1] with "awoo".