https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94939

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
t567.cc: In function ‘OldDerived callee(bool)’:
t567.cc:187:14: warning:
‘a.NewDerived::<anonymous>.type_safe::strong_typedef<NewDerived,
New>::value_.New::<anonymous>.Old::storage’ may be used uninitialized in this
function [-Wmaybe-uninitialized]
     return b ? a.toOld() : OldDerived::magic;
            ~~^~~~~~~~~~~~~~~~~~~~~~~~
t567.cc: In function ‘void caller_magic(bool)’:
t567.cc:187:14: warning: ‘a’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
     return b ? a.toOld() : OldDerived::magic;
            ~~^~~~~~~~~~~~~~~~~~~~~~~~


  MEM[(struct  &)&a] ={v} {CLOBBER};
  MEM[(struct strong_typedef *)&a] = 11;
  if (b_5(D) != 0)
    goto <bb 3>; [0.00%]
  else
    goto <bb 4>; [0.00%]

  <bb 3> [100.00%]:
  _7 = &MEM[(const struct New *)&a].D.43195;
  _13 = _7;
  iftmp.0_8 = _13;
  goto <bb 5>; [0.00%]

  <bb 4> [0.00%]:
  iftmp.0_6 = &magic;

  <bb 5> [0.00%]:
  # iftmp.0_1 = PHI <iftmp.0_8(3), iftmp.0_6(4)>
  D.48802 = *iftmp.0_1;
  a ={v} {CLOBBER};


Yes I think there is some aliasing issues in fact using -fno-strict-aliasing
"fixes" the warning and even gives what you expect.


And yes the code is undefined and violates aliasing.

NewDerived has no field or inheritance from OldDerived so mixing those together
like you with the casts is what causes the aliasing violations.

Reply via email to