llvm-project
llvm-project copied to clipboard
[clang] missed integer overflow warning with CXXTemporary values
compiler explorer link: https://godbolt.org/z/Wd318Mdrx
typedef long long int64_t;
template<typename T>
class u_ptr {
T *ptr;
public:
u_ptr(const u_ptr&) = delete;
u_ptr &operator=(const u_ptr&) = delete;
u_ptr(u_ptr &&other) : ptr(other.ptr) { other.ptr = 0; }
u_ptr(T *ptr) : ptr(ptr) { }
~u_ptr() { delete ptr; }
};
u_ptr<bool> Wrap(int64_t x) {
return nullptr;
}
int64_t Pass(int64_t x) { return x; }
int main(int argc, char* argv[]) {
// This trips -Winteger-overflow:
int64_t x = Pass(30 * 24 * 60 * 59 * 1000);
// This doesn't trip -Winteger-overflow.
auto r = Wrap(Pass(30 * 24 * 60 * 59 * 1000));
return 0;
}
Patch coming shortly.
@llvm/issue-subscribers-bug
Patch at https://reviews.llvm.org/D154253
@llvm/issue-subscribers-clang-frontend
Related: https://github.com/llvm/llvm-project/issues/58944