https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84151
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Status|UNCONFIRMED |NEW Last reconfirmed| |2018-02-01 Target Milestone|--- |6.5 Summary|[4.9/5/6/7 Regression] g++ |[6/7/8 Regression] g++ |generates two identical |generates two identical |loads in a |loads in a |volatile-qualified member |volatile-qualified member |function. |function. Ever confirmed|0 |1 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- The C++ FE generates ;; Function int A::foo() volatile (null) ;; enabled by -tree-original { int v; int v; <<cleanup_point <<< Unknown tree: expr_stmt (void) (v = (int) ((volatile struct A *) this)->c) >>>>>; <<cleanup_point return <retval> = *(volatile struct A *) this;, *A::bar ((int &) &v);>>; } which results in int A::foo() volatile (volatile struct A * const this) { int v; struct A vol.0; int _1; int & _2; int _8; <bb 2> [0.00%]: _1 ={v} this_4(D)->c; v = _1; vol.0 ={v} *this_4(D); _2 = A::bar (&v); _8 = *_2; v ={v} {CLOBBER}; return _8; I'm not sure how the behavior of a volatile this is specified but this unused copy of *this looks unwarranted.