this
is a prvalue, so decltype(this)
should always be plain X*
(or X cv*
/ cv X*
). The addition of const&
seems to be a bug in GCC (tested with g++ 4.8.1), which happens only for a class template (not for a “plain” class) and only inside the trailing return type (not inside the body of the member function): demo. This seems to be fixed in GCC 4.9 (experimental), you can test here.