-
Notifications
You must be signed in to change notification settings - Fork 13.3k
incorrect error on correct code and crash on bad code in forward declaration of enum in template #23317
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
Labels
bugzilla
Issues migrated from bugzilla
c++11
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
confirmed
Verified by a second party
crash
Prefer [crash-on-valid] or [crash-on-invalid]
Comments
Still crashing as of post-17 trunk: https://godbolt.org/z/9qeerY691
|
@llvm/issue-subscribers-clang-codegen |
If we look at this simpler example: https://godbolt.org/z/4sGr3TKPM struct A {
enum E :int ;
};
enum A::E :int { e1, e2 };
A::E er = e1; clang accepts while gcc/MSVC reject. It looks like we are missing a diagnostic here which would prevent this from going into codegen. |
@llvm/issue-subscribers-clang-frontend |
AaronBallman
added a commit
to AaronBallman/llvm-project
that referenced
this issue
Apr 9, 2025
Previously, the enumerators were being added both to the class context and to the namespace scope. e.g., we accepted this invalid code: struct A { enum E : int; }; enum A::E : int { e1 = 100, e2 }; int func() { return e1; // Was accepted, now correctly rejected } Fixes llvm#23317
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bugzilla
Issues migrated from bugzilla
c++11
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
confirmed
Verified by a second party
crash
Prefer [crash-on-valid] or [crash-on-invalid]
Extended Description
template struct A {
enum E : T;
};
A a;
template enum A::E : T { e1, e2 };
#if _WRONG
A::E er = e1;
#else
A::E e = A::e1;
#endif
Should compile clean but with
clang++ -std=c++11
a.cpp:9:15: error: no member named 'e1' in 'A'; did you mean simply 'e1'?
A::E e = A::e1;
^~~~~~~~~~
e1
a.cpp:5:38: note: 'e1' declared here
template enum A::E : T { e1, e2 };
clang++ -std=c++11 -D_WRONG
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 3.5.0 (tags/RELEASE_350/final)
Target: powerpc64le-unknown-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg:
Testcase (not _WRONG) section is taken directly from the C++2011 standard
14.5.1.4 Enumeration members of class templates
the _WRONG section was an attempt to fix according to the clang diagnostic message.
The text was updated successfully, but these errors were encountered: