Bug 54913 - [4.8 Regression] qualified lookup in ctor of class template fails to find static member of reference type
Summary: [4.8 Regression] qualified lookup in ctor of class template fails to find sta...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.0
: P2 normal
Target Milestone: 4.8.0
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2012-10-12 17:00 UTC by Jonathan Wakely
Modified: 2012-12-06 20:23 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.6.3, 4.7.1
Known to fail:
Last reconfirmed: 2012-12-03 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2012-10-12 17:00:43 UTC
struct Node { };

struct E
{
    class K {};
    static const K &N;

    int f(Node&, const K&);
};

template<typename T>
struct R : Node
{
        R(E &g)
        : r(g.f(*this,E::N))
        {}

    int r;
};


int main()
{
    E e;
    R<int> n(e);
}


e.cc: In instantiation of 'R<T>::R(E&) [with T = int]':
e.cc:25:15:   required from here
e.cc:15:21: error: '#'indirect_ref' not supported by dump_decl#<declaration error>' is not a member of 'E'
  : r(g.f(*this,E::N))
                     ^
Comment 1 Jonathan Wakely 2012-10-12 17:02:17 UTC
Fails with gcc version 4.8.0 20121007 (experimental) (GCC)

The code should be accepted, and the diagnostic should make sense!
Comment 2 Paolo Carlini 2012-10-12 17:13:08 UTC
The diagnostic issue is known (PR51413). Can you please figure out when it started?
Comment 3 Jonathan Wakely 2012-10-13 00:00:00 UTC
I'll bisect ...
Comment 4 Jonathan Wakely 2012-10-13 13:35:23 UTC
d0b4bf064cc775c510f804bee8394067530cc2bb is the first bad commit
commit d0b4bf064cc775c510f804bee8394067530cc2bb
Author: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri Aug 31 02:50:18 2012 +0000

        * semantics.c (finish_qualified_id_expr): Handle building up a
        non-dependent SCOPE_REF here.
        (finish_id_expression): Not here.
        * error.c (dump_decl) [SCOPE_REF]: Only pass TFF_UNQUALIFIED_NAME.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@190829 138bc75d-0d04-0410-961f-82ee72b054a4
Comment 5 Jonathan Wakely 2012-10-13 17:17:37 UTC
Reduced:

struct E
{
  static const int& e;
};

template<typename>
struct R
{
  R() { E::e; }
};

R<int> r;

The error goes away unless:

 - E::e is a reference
 - R is a template
 - the lookup is in a constructor
Comment 6 Richard Biener 2012-12-03 15:52:31 UTC
Confirmed.
Comment 7 Jason Merrill 2012-12-06 20:21:01 UTC
Author: jason
Date: Thu Dec  6 20:20:52 2012
New Revision: 194266

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194266
Log:
	PR c++/54913
	* semantics.c (finish_qualified_id_expr): convert_from_reference
	after building a SCOPE_REF.

Added:
    trunk/gcc/testsuite/g++.dg/template/qualified-id6.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/semantics.c
Comment 8 Jason Merrill 2012-12-06 20:23:05 UTC
Fixed.