Issue |
130556
|
Summary |
lang does not warn about redeclaration of type aliases within lambda-like construct
|
Labels |
new issue
|
Assignees |
|
Reporter |
starbugs-qurong
|
When compiling the following C++ code with Clang, the compiler issues a warning about an unused _expression_ result but does not warn about the redeclaration of the same type alias within the same scope. According to C++ standards, redeclaring the same name within the same scope should either be allowed (if it's the same declaration) or result in a compilation error/warning.
Steps to Reproduce:
Compile the following code with Clang:
```cpp
template <typename T>
struct Test {
int f() {
int x = 0;
[x = x, &r = x] {
using ty1 = int; // First definition
using ty1 = decltype(x); // Redefinition (invalid)
};
return 0;
}
};
int main() {
Test<int> obj;
obj.f();
return 0;
}
Expected Behavior:
Clang should issue a warning or error about the redeclaration of ty1 and ty2 within the same scope.
Actual Behavior:
Clang only issues a warning about an unused _expression_ result.
Compiler Version:
Clang 19.0.0
Additional Information:
The use of based-range initializer lists in this manner might not be standard-compliant. However, even if the code is invalid, Clang should still provide a meaningful diagnostic about the redeclaration issue.
Compiler Explorer link: https://godbolt.org/z/Mf7c1zP4v
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs