[Bug c++/48518] Inconsistent instantiation behavior depending on operator overloading
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Apr 4 11:39:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48518
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-04-04 11:38:57 UTC ---
(In reply to comment #0)
> The following program instantiates wrap<Undefined>, but a very similar program
> that doesn't call an overloaded operator doesn't:
Neither does an even more similar program that calls the operator function
directly:
template <class C> struct scoped_ptr {
C& operator*() const {
return *ptr_;
}
C* ptr_;
};
template<class T> struct wrap {
T must_be_complete;
};
class Undefined;
struct S {
wrap<Undefined> &content() const {
// return *content_;
return content_.operator*();
}
scoped_ptr<wrap<Undefined> > content_;
};
So the difference seems to be how the operator is looked up, possibly related
to whether the built-in operator* is considered, so due to [over.match.oper].
More information about the Gcc-bugs
mailing list