Open
Description
In the following example, a constexpr function does not have to be evaluated at compile time, so the signed integer overflow is not diagnosed. Yet, it is folded at compile time which then prevents the UBsan instrumentation do be applied, so the signed overflow ends up being detected neither at compile-time nor runtime.
static constexpr int foo(int a, int b) { return a * b; }
int n = foo(INT_MAX, 4);
int main() { return n; }
https://godbolt.org/z/7e9e9zddh
The constexpr function is folded even without optimization and apparently before UBsan instrumentation. GCC does get it right.
Metadata
Metadata
Assignees
Labels
New/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"Problems related to constant folding in the optimizerProblems related to constant folding in the optimizer