http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59186
Marcel Wid changed:
What|Removed |Added
CC||osensei80 at gmail dot com
--- Comment #2 from Marcel Wid ---
§5.1.1/3 [expr.prim.general] states:
"If a declaration declares a member function or member function template of a
class X, the expression this is a prvalue of type “pointer to cv-qualifier-seq
X” between the optional cv-qualifer-seq and the end of the function-definition,
member-declarator, or declarator. It shall not appear before the optional
cv-qualifier-seq and it shall not appear within the declaration of a static
member function (although its type and value category are defined within a
static member function as they are within a non-static member function)."
Hence, I think gcc 4.9 is correct:
struct s {
auto f() -> decltype(this) { return this; } // `this` refers to `struct s`
void g() {
struct t {
decltype(this) g() { return static_cast(nullptr); } // same as above
auto h() -> decltype(this) { return static_cast(nullptr); } // here
`this` refers to the inner struct `t` and there is no conversion from `s*` to
`s::g()::t*`.
};
}
};