https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119141

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
```
#include <chrono>
#include <iostream>

[[gnu::noinline,gnu::noipa]]
void sink(auto)
{}

int main() {
    std::chrono::milliseconds ms = std::chrono::milliseconds::max();
    std::chrono::nanoseconds ns = ms;
    sink(ns);
}
```


Compile this with clang as `-std=c++23 -fsanitize=undefined -stdlib=libc++ `
and you get the overflow at runtime too.

GCC is not doing the constant folding at compile time and NOT ignorning the
overflow at compile time while clang is ignoring the overflow as it is done at
compile time.

Reply via email to