https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50462
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> --- Oh, it's the overloaded function thjat makes the difference between saying "invalid use of non-static member function" and trying to do overload resolution with an <unresolved overloaded function type>. Reduced example that actually reproduces the original problem: struct ostream { }; void operator<<(ostream, int) { } void operator<<(ostream, void*) { } void operator<<(ostream, char*) { } struct V { int size() { return 0; }; int size() const { return 0; }; }; void print(V v) { ostream() << v.size; } Which prints this with current trunk: 50462.C: In function 'void print(V)': 50462.C:14:13: error: no match for 'operator<<' (operand types are 'ostream' and '<unresolved overloaded function type>') 14 | { ostream() << v.size; } | ~~~~~~~~~ ^~ ~~~~~~ | | | | ostream <unresolved overloaded function type> 50462.C:3:6: note: candidate: 'void operator<<(ostream, int)' 3 | void operator<<(ostream, int) { } | ^~~~~~~~ 50462.C:3:26: note: no known conversion for argument 2 from '<unresolved overloaded function type>' to 'int' 3 | void operator<<(ostream, int) { } | ^~~ 50462.C:4:6: note: candidate: 'void operator<<(ostream, void*)' 4 | void operator<<(ostream, void*) { } | ^~~~~~~~ 50462.C:4:26: note: no known conversion for argument 2 from '<unresolved overloaded function type>' to 'void*' 4 | void operator<<(ostream, void*) { } | ^~~~~ 50462.C:5:6: note: candidate: 'void operator<<(ostream, char*)' 5 | void operator<<(ostream, char*) { } | ^~~~~~~~ 50462.C:5:26: note: no known conversion for argument 2 from '<unresolved overloaded function type>' to 'char*' 5 | void operator<<(ostream, char*) { } | ^~~~~ I don't see why we should treat v.size any differently whether it's overloaded or not. It's invalid either way, so we should fail similarly.