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