[Bug d/101282] New: d: RHS value lost when a target_expr appears in a cond_expr
ibuclaw at gdcproject dot org
gcc-bugzilla@gcc.gnu.org
Thu Jul 1 10:36:07 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101282
Bug ID: 101282
Summary: d: RHS value lost when a target_expr appears in a
cond_expr
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: d
Assignee: ibuclaw at gdcproject dot org
Reporter: ibuclaw at gdcproject dot org
Target Milestone: ---
The assignment ends up looking like:
a = opCmp (&a, 0) < 0 ? TARGET_EXPR <D.4074, opUnary (&a) [return slot
optimization]> : a;
---
void main()
{
struct CrippledInt
{
int impl;
CrippledInt opUnary(string op : "-")()
{
return CrippledInt(-impl);
}
int opCmp(int i) { return (impl < i) ? -1 : (impl > i) ? 1 : 0; }
}
auto a = CrippledInt(120);
a = -a;
assert(a.impl == -120);
a = a >= 0 ? a : -a;
assert(a.impl == 120); // fails
}
More information about the Gcc-bugs
mailing list