Bug 24163 - dependent Base class scope examined during unqualified name lookup in template
Summary: dependent Base class scope examined during unqualified name lookup in template
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.7.0
Assignee: Jason Merrill
URL:
Keywords: accepts-invalid
: 42291 43282 47585 47752 51699 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-10-01 16:24 UTC by Jonathan Wakely
Modified: 2012-01-18 03:04 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 2.95.3, 3.0.4, 3.2.3, 3.3.1, 3.3.3, 3.4.3, 4.0.0, 4.1.2, 4.3.1, 4.4.3, 4.5.2
Last reconfirmed: 2005-10-01 16:28:10


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2005-10-01 16:24:48 UTC
(I first posted this code to PR5660 but it's apparently a separate issue)

   template <typename T>
     struct A
     {
         typedef T Type;
         void f(Type) {}
     };

   template <typename T>
     struct B : A<T>
     {
         typedef typename A<T>::Type Type;
         void ff(Type t) { f(t); }         // XXX
     };

   template struct B<int>;

This should fail to compile, according to 14.6.2/3, but 3.4 - 4.1 (and probably
earlier) accept it.

If A::f and the call to it are changed to take no arguments (so that f is not a
dependent name) then it fails, so it is apparently only at instantiation that
the base class scope is examined.
Comment 1 Andrew Pinski 2005-10-01 16:28:10 UTC
Confirmed.
Comment 2 Jonathan Wakely 2005-10-01 16:48:44 UTC
Adding "... in template" to end of title.
Comment 3 Andrew Pinski 2009-12-05 00:01:56 UTC
*** Bug 42291 has been marked as a duplicate of this bug. ***
Comment 4 Andrew Pinski 2009-12-05 00:03:48 UTC
This is related to PR 15272 where we look at both dependent and non dependent base classes when only non dependent should be looked at.  Actually I think this is a dup of that bug but I will leave it to a C++ expert.
Comment 5 Andrew Pinski 2010-11-30 19:14:37 UTC
*** Bug 43282 has been marked as a duplicate of this bug. ***
Comment 6 Jonathan Wakely 2011-02-02 11:57:52 UTC
*** Bug 47585 has been marked as a duplicate of this bug. ***
Comment 7 Jason Merrill 2011-05-20 18:01:27 UTC
Author: jason
Date: Fri May 20 18:01:22 2011
New Revision: 173965

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173965
Log:
	PR c++/24163
	PR c++/29131
gcc/cp/
	* pt.c (tsubst_copy_and_build) [CALL_EXPR]: Avoid repeating
	unqualified lookup.
	* semantics.c (perform_koenig_lookup): Add complain parm.
	* cp-tree.h: Adjust.
	* parser.c (cp_parser_postfix_expression): Adjust.
	(cp_parser_perform_range_for_lookup): Adjust.
libstdc++-v3/
	* include/ext/pb_ds/assoc_container.hpp: Explicitly qualify calls to
	functions from dependent bases.
	* include/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp: Likewise.
	* include/ext/pb_ds/detail/rb_tree_map_/
	split_join_fn_imps.hpp: Likewise.
	* include/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp: Likewise.
	* include/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp: Likewise.
	* include/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp: Likewise.
	* include/ext/pb_ds/detail/splay_tree_/
	split_join_fn_imps.hpp: Likewise.
	* include/ext/pb_ds/detail/tree_policy/
	order_statistics_imp.hpp: Likewise.
	* include/ext/pb_ds/detail/trie_policy/
	prefix_search_node_update_imp.hpp: Likewise.
	* include/ext/rc_string_base.h: Likewise.
	* include/ext/rope: Likewise.
	* include/ext/ropeimpl.h: Likewise.
	* testsuite/util/exception/safety.h: Likewise.
	* testsuite/util/native_type/native_priority_queue.hpp: Likewise.
	* testsuite/util/testsuite_io.h: Likewise.
	* include/std/functional: Declare mem_fn earlier.
	* include/tr1/functional: Likewise.
	* include/tr1/exp_integral.tcc: Declare __expint_E1 earlier.

Added:
    trunk/gcc/testsuite/g++.dg/template/koenig9.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/parser.c
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/opt/pr47615.C
    trunk/gcc/testsuite/g++.dg/overload/defarg1.C
    trunk/gcc/testsuite/g++.dg/tc1/dr213.C
    trunk/gcc/testsuite/g++.dg/torture/pr34850.C
    trunk/gcc/testsuite/g++.dg/torture/pr39362.C
    trunk/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C
    trunk/gcc/testsuite/g++.old-deja/g++.pt/memtemp47.C
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/ext/pb_ds/assoc_container.hpp
    trunk/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp
    trunk/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp
    trunk/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp
    trunk/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp
    trunk/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp
    trunk/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp
    trunk/libstdc++-v3/include/ext/pb_ds/detail/tree_policy/order_statistics_imp.hpp
    trunk/libstdc++-v3/include/ext/pb_ds/detail/trie_policy/prefix_search_node_update_imp.hpp
    trunk/libstdc++-v3/include/ext/rc_string_base.h
    trunk/libstdc++-v3/include/ext/rope
    trunk/libstdc++-v3/include/ext/ropeimpl.h
    trunk/libstdc++-v3/include/std/functional
    trunk/libstdc++-v3/include/tr1/exp_integral.tcc
    trunk/libstdc++-v3/include/tr1/functional
    trunk/libstdc++-v3/testsuite/util/exception/safety.h
    trunk/libstdc++-v3/testsuite/util/native_type/native_priority_queue.hpp
    trunk/libstdc++-v3/testsuite/util/testsuite_io.h
Comment 8 Jason Merrill 2011-05-20 18:57:08 UTC
Fixed for 4.7.
Comment 9 Jason Merrill 2011-07-07 21:29:33 UTC
*** Bug 47752 has been marked as a duplicate of this bug. ***
Comment 10 Jonathan Wakely 2011-12-29 14:45:14 UTC
*** Bug 51699 has been marked as a duplicate of this bug. ***
Comment 11 Zooko Wilcox-O'Hearn 2012-01-18 03:04:04 UTC
Here is a launchpad ticket tracking the effect of this bugfix on various open source projects that were depending on the bug: https://bugs.launchpad.net/cryptopp/+bug/915018