Bug 11786 - [3.3/3.4 regression] operator() call on variable in other namespace not recognized
Summary: [3.3/3.4 regression] operator() call on variable in other namespace not recog...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P1 normal
Target Milestone: 3.3.2
Assignee: Not yet assigned to anyone
URL:
Keywords: monitored, rejects-valid
Depends on:
Blocks:
 
Reported: 2003-08-04 06:32 UTC by Eelis
Modified: 2004-01-17 04:22 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-09-07 04:41:47


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eelis 2003-08-04 06:32:02 UTC
GCC rejects the following valid code:

  struct S
  {
    template <typename T> void operator() (T) {}
  };

  namespace N
  {
    S s;
    struct A {} a;
  }

  using N::s;

  void f () { s(N::a); }

GCC says:

  t.cpp:8: error: `N::s' is not a function,
  t.cpp:8: error:   conflict with `N::s'
  t.cpp:14: error:   in call to `s'

My best guess would be that GCC does not recognize s(..) as a call to operator()
on _variable_ N::s, and as such insists on finding a _function_ named 'N::s'. I
haven't got a clue as to what the rest of the error message indicates or how A
is involved.

Comeau compiles the code without problems.

I'm using GCC 3.4 20030723.
Comment 1 Eelis 2003-08-04 07:28:00 UTC
Simplified snippet:

  namespace N
  {
    struct A {};
    struct S { void operator() (A); } s;
  }

  using N::s;

  void f () { s(N::A()); }
Comment 2 Andrew Pinski 2003-08-04 19:46:42 UTC
I can confirm this on the mainline (20030804).  ICC 6.0 in strict mode (-Xc) accepts this 
code.
Comment 3 Volker Reichelt 2003-08-04 23:02:14 UTC
gcc 2.95.x compiled the code. It is rejected since gcc 3.0.
Comment 4 CVS Commits 2003-09-08 18:46:24 UTC
Subject: Bug 11786

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2003-09-08 18:46:20

Modified files:
	gcc/cp         : ChangeLog decl2.c semantics.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/lookup: koenig2.C 

Log message:
	PR c++/11786
	* decl2.c (add_function): Do not complain about seeing the same
	non-function twice.
	* semantics.c (perform_koenig_lookup): Improve documentation.
	
	PR c++/11786
	* g++.dg/lookup/koenig2.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3661&r2=1.3662
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.669&r2=1.670
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/semantics.c.diff?cvsroot=gcc&r1=1.357&r2=1.358
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3041&r2=1.3042
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/koenig2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 6 Mark Mitchell 2003-09-08 19:15:32 UTC
Fixed in GCC 3.3.2, GCC 3.4.