Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement CWG2685: Aggregate CTAD, string, and brace elision #95383

Open
hokein opened this issue Jun 13, 2024 · 5 comments
Open

Implement CWG2685: Aggregate CTAD, string, and brace elision #95383

hokein opened this issue Jun 13, 2024 · 5 comments
Assignees
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@hokein
Copy link
Collaborator

hokein commented Jun 13, 2024

see https://cplusplus.github.io/CWG/issues/2685.html

@hokein hokein added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jun 13, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 13, 2024

@llvm/issue-subscribers-clang-frontend

Author: Haojian Wu (hokein)

see https://cplusplus.github.io/CWG/issues/2685.html

@zyn0217
Copy link
Contributor

zyn0217 commented Jun 13, 2024

I think that has already been implemented? See the test in 3475116

@hokein
Copy link
Collaborator Author

hokein commented Jun 13, 2024

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"};

@zyn0217
Copy link
Contributor

zyn0217 commented Jun 13, 2024

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.

Edit: #95389

@zyn0217
Copy link
Contributor

zyn0217 commented Jun 13, 2024

(Assigned it to myself in the hope that I would be able to look into it in the next few days.)

@zyn0217 zyn0217 self-assigned this Jun 13, 2024
@EugeneZelenko EugeneZelenko removed the clang Clang issues not falling into any other category label Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

4 participants