https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120270
Bug ID: 120270
Summary: ICE with -O1 in expand_debug_locations, at
cfgexpand.cc:5668
Product: gcc
Version: unknown
URL: https://godbolt.org/z/M3dTTzoWc
Status: UNCONFIRMED
Keywords: ice-on-valid-code
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: aozgaa at gmail dot com
Target Milestone: ---
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build: x86_64-pc-linux-gnu
The following code generates an ICE with g++ starting at v13.1 (repros with
14.x and 15.x series as well), when compiled with -O1 (-O0, -O2, and -O3
compile without error):
```
typedef long int64_t;
namespace std {
enum _Ord { equivalent, less = -1, greater = 1 };
struct __unspec {
__unspec(__unspec *);
};
struct partial_ordering {
char _M_value;
partial_ordering(_Ord __v) : _M_value(__v) {}
friend bool operator>=(partial_ordering __v, __unspec) {
return (__v._M_value & 1) == __v._M_value;
}
};
struct strong_ordering {
char _M_value;
static const strong_ordering less;
static const strong_ordering equal;
static const strong_ordering greater;
operator partial_ordering() { return _Ord(_M_value); }
} constexpr strong_ordering::less(_Ord::less);
constexpr strong_ordering strong_ordering::equal(equivalent);
constexpr strong_ordering strong_ordering::greater(_Ord::greater);
struct CmpV {
auto operator<=>(CmpV rhs) {
return partial_ordering(value_ <=> rhs.value_);
}
int64_t value_;
} __trans_tmp_1;
void func() {
auto bb = CmpV(), ba = __trans_tmp_1;
bool b = bb >= ba;
if (b)
return;
}
} // namespace std
```
(reduced with cvise)
The error is
```
during RTL pass: expand
<source>: In function 'void std::func()':
<source>:29:6: internal compiler error: in expand_debug_locations, at
cfgexpand.cc:5668
29 | void func() {
| ^~~~
0x2a1bc8c internal_error(char const*, ...)
???:0
0xe643f8 fancy_abort(char const*, int, char const*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
```
Togglable compilers at https://godbolt.org/z/M3dTTzoWc