Why GCC 5.3.0 gives warning when binding reference to “this” pointer
问题 Here is the minimal example: class A { A* const& this_ref; public: A() : this_ref(this) {} }; GCC 5.3.0 gives warning: warning: a temporary bound to 'A::this_ref' only persists until the constructor exits [-Wextra] A() : this_ref(this) {} Is this a temporary then? What the... MSVC 2015 is silent about this, and referring to class members by this_ref->member outside the constructor in my case gives expected behaviour (but might be just a case of UB, not sure). EDIT: Note this question extends