Bug 61161 - wrong two-stage name lookup for overloaded operators
Summary: wrong two-stage name lookup for overloaded operators
Status: RESOLVED DUPLICATE of bug 51577
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Blocks: 12944
  Show dependency treegraph
Reported: 2014-05-12 21:09 UTC by Richard Smith
Modified: 2014-05-12 23:45 UTC (History)
1 user (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Richard Smith 2014-05-12 21:09:34 UTC
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;

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.
Comment 1 Jonathan Wakely 2014-05-12 22:22:20 UTC
Maybe related to PR51577
Comment 2 Richard Smith 2014-05-12 23:45:22 UTC
(In reply to Jonathan Wakely from comment #1)
> Maybe related to PR51577

Thanks, I'm pretty sure it's the same thing, dup'ing.

*** This bug has been marked as a duplicate of bug 51577 ***