-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[clang] Invalid rejection of enum arithmetic #84712
Comments
@llvm/issue-subscribers-clang-frontend Author: David Stone (davidstone)
The following valid translation unit
enum e1 {
value = 0
};
enum e2 {
a = 0,
b = e1::value,
c = a + b
}; is incorrectly rejected by clang when compiled in C++26 mode with <source>:8:8: error: invalid arithmetic between different enumeration types ('e2' and 'e1')
8 | c = a + b
| ~ ^ ~
1 error generated.
Compiler returned: 1 See it live: https://godbolt.org/z/v4sG9YqMb In earlier versions of C++, it incorrectly warns saying the conversion is deprecated. This was accepted in clang 18.1.0, but is failing on current trunk (15e9478). |
This seems to be a bug, yeah. The type of |
Related: #84068 |
Ah, I somehow was under the impression that that had already been merged. |
Enumerators dont have the type of their enumeration before the closing brace. In these cases Expr::getEnumCoercedType() incorrectly returned the enumeration type. Introduced in PR llvm#81418 Fixes llvm#84712
Enumerators dont have the type of their enumeration before the closing brace. In these cases Expr::getEnumCoercedType() incorrectly returned the enumeration type. Introduced in PR llvm#81418 Fixes llvm#84712
The following valid translation unit
is incorrectly rejected by clang when compiled in C++26 mode with
See it live: https://godbolt.org/z/v4sG9YqMb
In earlier versions of C++, it incorrectly warns saying the conversion is deprecated.
This was accepted in clang 18.1.0, but is failing on current trunk (15e9478).
The text was updated successfully, but these errors were encountered: