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++/61161] New: wrong two-stage name lookup for overloaded operators


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61161

            Bug ID: 61161
           Summary: wrong two-stage name lookup for overloaded operators
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: richard-gccbugzilla at metafoo dot co.uk

GCC rejects-valid on this:

struct T {
  template<typename T> void f(const T &v) {
    0 << v;
  }
};

namespace N {
  struct X {};
  struct Y : X {};
  void operator<<(int, const X&) {}
}

void operator<<(int, const N::Y&) = delete;

int main() {
  N::Y d;
  T().f(d);
}

This is valid because the deleted operator<< is found by neither unqualified
lookup (within the template) or argument-dependent lookup (which searches
namespace N and not the global namespace).

This seems to be specific to operator syntax; if 'f' is changed to

  operator<<(0, v);

then the code is accepted.


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