Bug 117255 - There is a core language undefined behavior in the constexpr function, but GCC did not report the error
Summary: There is a core language undefined behavior in the constexpr function, but GC...
Status: RESOLVED DUPLICATE of bug 102284
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks: constexpr
  Show dependency treegraph
 
Reported: 2024-10-22 07:32 UTC by qurong
Modified: 2024-10-22 09:08 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description qurong 2024-10-22 07:32:22 UTC
This causes an error in clang, but GCC didn't report the error. There is a core language undefined behavior in the constexpr function:



```
struct A {
    constexpr ~A() {}
};

constexpr int foo() {
    A a;
    a.~A();
    return 0;
}

int main() {
    constexpr auto x = foo();
    return x;
}
```

Compiler Explorer link: https://godbolt.org/z/PMfv8G9ev

This code compiles an error with Clang and MSVC.
Comment 1 Drea Pinski 2024-10-22 07:45:11 UTC
Dup.

*** This bug has been marked as a duplicate of bug 102284 ***