Bug 35650 - [4.1/4.2/4.3/4.4 Regression] Can't bind ref-to-function through using-decl. in namespace
Summary: [4.1/4.2/4.3/4.4 Regression] Can't bind ref-to-function through using-decl. i...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.4.0
: P2 normal
Target Milestone: 4.1.3
Assignee: Jakub Jelinek
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2008-03-20 18:06 UTC by Eelis
Modified: 2008-04-29 09:06 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.6
Known to fail: 3.4.6
Last reconfirmed: 2008-04-22 07:37:27


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eelis 2008-03-20 18:06:28 UTC
Consider:

  void f();
  namespace N { using ::f; }

  void h()
  {
    void (& a)() = f; // ok
    void (& b)() = N::f;
      // error: invalid initialization of non-const reference of
      // type ‘void (&)()’ from a temporary of type ‘void ()()’
  }

Since in h, f and N::f are simply two ways of naming the same function, the error seems unwarranted to me.

Comeau 4.3.9 accepts the code.
Comment 1 Richard Biener 2008-03-20 19:55:23 UTC
Confirmed.  Fails since 3.4.
Comment 2 Wolfgang Bangerth 2008-03-25 19:02:14 UTC
Confirmed again. Funny enough, this works:
-----------------
void f();
namespace N { using ::f; }

void h()
{
  void (& b)() = N::f;   // not ok
  void (& c)() = *&N::f; // ok!?
}
-----------------

W.
Comment 3 Jakub Jelinek 2008-04-29 08:59:07 UTC
Subject: Bug 35650

Author: jakub
Date: Tue Apr 29 08:58:20 2008
New Revision: 134788

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134788
Log:
	PR c++/35650
	* parser.c (cp_parser_lookup_name): Look through single function
	OVERLOAD.

	* g++.dg/init/ref17.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/init/ref17.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog

Comment 4 Jakub Jelinek 2008-04-29 08:59:55 UTC
Subject: Bug 35650

Author: jakub
Date: Tue Apr 29 08:58:58 2008
New Revision: 134789

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134789
Log:
	PR c++/35650
	* parser.c (cp_parser_lookup_name): Look through single function
	OVERLOAD.

	* g++.dg/init/ref17.C: New test.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/g++.dg/init/ref17.C
Modified:
    branches/gcc-4_3-branch/gcc/cp/ChangeLog
    branches/gcc-4_3-branch/gcc/cp/parser.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 5 Jakub Jelinek 2008-04-29 09:06:32 UTC
Fixed.