Open hokein opened 3 months ago
@llvm/issue-subscribers-clang-frontend
Author: Haojian Wu (hokein)
I think that has already been implemented? See the test in https://github.com/llvm/llvm-project/commit/3475116e2c37a2c8a69658b36c02871c322da008
I didn't see any related implementation for the rule an array type with a dependent array element type and x_i is a string literal
in clang.
Yeah, clang accepts the testcase, but the result seems incorrect:
template <class T>
struct A {
T ar[4];
};
A a = {"foo"};
Here, the template argument T
is deduced as const char*
, but I believe the expected result is char
.
Clang also accepts the following case, I think it should be rejected as brace elision is not considered for string literals:
template <class T>
struct A {
T ar[4];
};
A a = {"a", "b", "c", "d"};
It's interesting to note that all compilers accept the case https://godbolt.org/z/WhPo939f7 (MSVC is seemingly unavailable at the moment) I reread the CWG issue and now I changed my mind that we probably should reject such a case. And sorry for merging that PR recklessly - I'll revert it shortly.
(Assigned it to myself in the hope that I would be able to look into it in the next few days.)
see https://cplusplus.github.io/CWG/issues/2685.html