https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635
--- Comment #58 from Martin Sebor <msebor at gcc dot gnu.org> ---
Jeff's POC also suggests a workaround: changing the type of
_Optional_payload_base::_M_engaged from bool to unsigned char avoids the
VIEW_CONVERT_EXPR and avoids the warning. The difference in the uninit IL is
below but there's no difference in the assembly.
{
- unsigned char maybe_a$4;
+ unsigned char maybe_a$_M_payload$D12141$D11991$_M_engaged;
int maybe_a$m_val;
struct optional maybe_b;
struct optional maybe_a;
- bool _11;
- bool _12;
+ unsigned char _11;
int _29;
- bool _32;
+ unsigned char _32;
<bb 2> [local count: 1073741824]:
maybe_b = {};
@@ -53,7 +52,7 @@
<bb 9> [count: 0]:
# maybe_a$m_val_51 = PHI <_29(6), maybe_a$m_val_38(D)(8)>
- # maybe_a$4_54 = PHI <1(6), 0(8)>
+ # maybe_a$_M_payload$D12141$D11991$_M_engaged_54 = PHI <1(6), 0(8)>
<L0>:
_11 = MEM[(struct _Optional_payload_base *)&maybe_b]._M_engaged;
if (_11 != 0)
@@ -74,8 +73,7 @@
<bb 12> [count: 0]:
<L1>:
- _12 = VIEW_CONVERT_EXPR<bool>(maybe_a$4_54);
- if (_12 != 0)
+ if (maybe_a$_M_payload$D12141$D11991$_M_engaged_54 != 0)
goto <bb 13>; [0.00%]
else
goto <bb 17>; [0.00%]