This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/48518] Inconsistent instantiation behavior depending on operator overloading


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].


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]