https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116168
Bug ID: 116168
Summary: Segmentation fault when compiling user-defined
partial_ordering
Product: gcc
Version: 14.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: daidodo at gmail dot com
Target Milestone: ---
Created attachment 58790
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58790&action=edit
Details of the segment fault.
Hi,
The following code will cause Segmentation Fault when compiled with G++ 14.1.0:
```
// g++ main.cpp -std=c++23
namespace my
{
struct partial_ordering
{
signed char v_;
static const partial_ordering less;
static const partial_ordering equivalent;
static const partial_ordering greater;
static const partial_ordering unordered;
};
constexpr partial_ordering partial_ordering::less{-1};
constexpr partial_ordering partial_ordering::equivalent{0};
constexpr partial_ordering partial_ordering::greater{1};
constexpr partial_ordering partial_ordering::unordered{2};
}
namespace std
{
using partial_ordering = my::partial_ordering;
}
int main() {
auto a = 1.0 <=> 2.0;
}
```
I understand it may not be recommended to "replace" std::partial_ordering in
practice. But I'd expect more useful error messages when a user does so,
instead of a segment fault with encrypted text.
I've attached the -freport-bug result.
Thanks,
Zhao