Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

UBsan instrumentation missing in constexpr function #109239

Copy link
Copy link
Open
@uecker

Description

@uecker
Issue body actions

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

No one assigned

    Labels

    clang:diagnosticsNew/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 analyzerclang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"constant-foldingProblems related to constant folding in the optimizerProblems related to constant folding in the optimizer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.