Edit : actually bothered to check my theory, it turned out that I was wrong, in this context decltype(t) is Test , which can be shown static_assert(std::is_same<decltype(t), Test>::value, "not a reference")
So ICC (or the external EDG interface that it uses) probably just doesn't support decltype support in nested qualifiers, which was changed by DR 743
Using std::decay makes ICC acceptable, and therefore a useful solution.
Original, wrong, answer :
I think the ICC here, decltype(object) is actually Test& , and the reference type cannot have members, therefore &decltype(t)::memfn poorly formed.
The code can be simplified to:
struct Test { void foo() {} }; int main() { Test t; auto p = &decltype(t)::foo; }
Which g ++ and Clang accept, but ICC rejects, correctly IMHO.
You can fix this using std::remove_reference or std::decay
#include <type_traits> // ... Test t; auto p = &std::decay<decltype(t)>::type::foo;
source share