This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/48518] Inconsistent instantiation behavior depending on operator overloading
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 04 Apr 2012 11:38:57 +0000
- Subject: [Bug c++/48518] Inconsistent instantiation behavior depending on operator overloading
- Auto-submitted: auto-generated
- References: <bug-48518-4@http.gcc.gnu.org/bugzilla/>
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].