Issue |
142248
|
Summary |
Clang does not warn on undefined shift in templated member function when using conditional _expression_
|
Labels |
clang
|
Assignees |
|
Reporter |
pkennedyTT
|
As title says, clang doesn't warn about UB due to shifting beyond the width of type in specific circumstances.
Clang version:
Apple clang version 16.0.0 (clang-1600.0.26.6)
Target: arm64-apple-darwin23.6.0
Compile flags: `-std=c++20 -Wall -Wextra -Wshift-count-overflow -pedantic`
```
#include <iostream>
#include <type_traits>
template <typename T>
class Foo {
public:
T foo() {
return std::is_same_v<T, uint64_t> ? (1<<32): 0; // No warning here
}
};
template <typename T>
T bar() {
return std::is_same_v<T, uint64_t> ? (1<<32): 0; // Warning here
}
int main()
{
Foo<uint64_t> f;
std::cout << f.foo() << " " << bar<uint64_t>() << "\n";
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs