https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95221
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
It is caused by this code:
853 if (flag_strong_eval_order == 2
854 && CALL_EXPR_FN (*expr_p)
855 && cp_get_callee_fndecl_nofold (*expr_p) == NULL_TREE)
856 {
857 tree fnptrtype = TREE_TYPE (CALL_EXPR_FN (*expr_p));
858 enum gimplify_status t
859 = gimplify_to_rvalue (&CALL_EXPR_FN (*expr_p), pre_p, NULL,
860 is_gimple_call_addr);
861 if (t == GS_ERROR)
862 ret = GS_ERROR;
863 /* GIMPLE considers most pointer conversion useless, but for
864 calls we actually care about the exact function pointer type.
*/
865 else if (TREE_TYPE (CALL_EXPR_FN (*expr_p)) != fnptrtype)
866 CALL_EXPR_FN (*expr_p)
867 = build1 (NOP_EXPR, fnptrtype, CALL_EXPR_FN (*expr_p));
868 }
and causes this difference:
--- 1g 2020-05-19 11:42:32.123168379 -0400
+++ 2g 2020-05-19 11:42:41.254133594 -0400
@@ -18,21 +18,21 @@
operator delete (D.2725, 8);
}
c = D.2725;
+ _1 = c->_vptr.MyClass;
+ _2 = *_1;
c.0 = c;
- _1 = c.0->_vptr.MyClass;
- _2 = (long unsigned int) _1;
- .UBSAN_VPTR (c.0, _2, 2968783897514143607, &_ZTI7MyClass, 4B);
- _3 = c->_vptr.MyClass;
- _4 = *_3;
- OBJ_TYPE_REF(_4;(struct MyClass)c->0) (c.0);
+ _3 = c.0->_vptr.MyClass;
+ _4 = (long unsigned int) _3;
+ .UBSAN_VPTR (c.0, _4, 2968783897514143607, &_ZTI7MyClass, 4B);
+ OBJ_TYPE_REF(_2;(struct MyClass)c->0) (c.0);
+ _5 = c->_vptr.MyClass;
+ _6 = _5 + 16;
+ _7 = *_6;
c.1 = c;
- _5 = c.1->_vptr.MyClass;
- _6 = (long unsigned int) _5;
- .UBSAN_VPTR (c.1, _6, 2968783897514143607, &_ZTI7MyClass, 4B);
- _7 = c->_vptr.MyClass;
- _8 = _7 + 16;
- _9 = *_8;
- OBJ_TYPE_REF(_9;(struct MyClass)c->2) (c.1);
+ _8 = c.1->_vptr.MyClass;
+ _9 = (long unsigned int) _8;
+ .UBSAN_VPTR (c.1, _9, 2968783897514143607, &_ZTI7MyClass, 4B);
+ OBJ_TYPE_REF(_7;(struct MyClass)c->2) (c.1);
D.2751 = 0;
return D.2751;
}