Bug 47752 - Non-dependent name is found in dependent base class although it should be rejected
Non-dependent name is found in dependent base class although it should be rej...
Status: RESOLVED DUPLICATE of bug 24163
Product: gcc
Classification: Unclassified
Component: c++
4.5.2
: P3 normal
: 4.7.0
Assigned To: Not yet assigned to anyone
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-02-15 13:47 UTC by Volker H. Simonis
Modified: 2011-07-07 21:29 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-02-15 14:52:21


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker H. Simonis 2011-02-15 13:47:51 UTC
Consider the following example:

===================================================

template<typename T> struct B {
  void f(int i) { }
  void f2() { }
};

template<typename T> struct D : public B<T> {
  int foo(int i) {
    return i;
  }
  void g() {
    // f(42);   // (1)
    f(foo(42)); // (2)
    // f2();    // (3)
  }
}; 

struct E : public D<int> {
  void h() {
    g();
  }
};

=====================================================

This compiles fine with g++ 4.5.2.
If one of the lines (1) or (2) is uncommented, the compilation fails with:

dependent2.cpp:11: error: there are no arguments to ‘f’ that depend on a template parameter, so a declaration of ‘f’ must be available
dependent2.cpp:13: error: there are no arguments to ‘f2’ that depend on a template parameter, so a declaration of ‘f2’ must be available

I think the compilation of the call 'f(foo(42))' should fail for the same reason.

Regards,
Volker
Comment 1 Jonathan Wakely 2011-02-15 14:52:21 UTC
confirmed, not a regression

I don't think this is a dup of any existing bugs relating to lookup in dependent bases
Comment 2 Dodji Seketeli 2011-02-15 15:36:59 UTC
I am no C++ Language Lawyer but my understanding is that G++ considers foo in f(foo(42)) as
being type dependent. This looks somewhat related to C++ Core
Working Group issue
http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_active.html#1005 and I
heard that this issue is being presently discussed.

PR c++/47172 is also (remotely) related to this.
Comment 3 Jason Merrill 2011-07-07 21:29:33 UTC
Fixed for 4.7.

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