https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80456
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> --- With the volatile, cxx_eval_constant_expression sees *(volatile struct A *) this;, A::test(); and it's not able to evaluate 'this' in it. Without the volatile it only sees A::test() which it can evaluate. The COMPOUND_EXPR comes from build_new_method_call_1: 8827 /* In an expression of the form `a->f()' where `f' turns 8828 out to be a static member function, `a' is 8829 none-the-less evaluated. */ 8830 if (TREE_CODE (TREE_TYPE (fn)) != METHOD_TYPE 8831 && !is_dummy_object (instance) 8832 && TREE_SIDE_EFFECTS (instance)) 8833 call = build2 (COMPOUND_EXPR, TREE_TYPE (call), 8834 instance, call);