public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/29229] New: g++ fails to find dependent name in template from instantiation context
@ 2006-09-25 22:48 debian-gcc at lists dot debian dot org
2006-09-25 22:54 ` [Bug c++/29229] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: debian-gcc at lists dot debian dot org @ 2006-09-25 22:48 UTC (permalink / raw)
To: gcc-bugs
[forwarded from http://bugs.debian.org/385992]
Matthias
bug submitter writes:
It appears that g++ no longer finds a dependent name when it is the
template function itself.
$cat -n test.cpp
1 template <class C> void f(C *p)
2 { f(*p); }
3
4 void f(int i)
5 { i++; }
6
7 int main(int argc, char**)
8 { f(&argc); }
$g++-4.0 -o test test.cpp
$g++-4.1 -o test test.cpp
test.cpp: In function 'void f(C*) [with C = int]':
test.cpp:8: instantiated from here
test.cpp:2: error: no matching function for call to 'f(int&)'
$
To my understanding from the C++ standard, g++-4.0 behaves correctly.
My reasoning:
In f(*p), f is a dependent name according to clause 14.6.2, para 1.
The point of instantiation is f(&argc).
In f(*p), f is an unqualified-id but not a template-id, so 14.6.4.2
applies: only functions with external linkage will be found. However,
f(int) has external linkage.
Name lookup (3.4, 3.4.2) does not distinguish between the different
contexts for the case of an instantiated instantiation.
So, the lookup of f in f(*p) should consider f<C>(C*) and f(int) together,
and select f(int) from them.
When f(int) and its call in the template are renamed to something else,
the lookup succeeds. I do not know of a reason for having template f
hide the existence of function f.
g++ -v output for upstream:
$g++-4.1 -v -o test test.cpp
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-mpfr --with-tune=i686
--enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20060814 (prerelease) (Debian 4.1.1-11)
/usr/lib/gcc/i486-linux-gnu/4.1.2/cc1plus -quiet -v -D_GNU_SOURCE test.cpp
-quiet -dumpbase test.cpp -mtune=i686 -auxbase test -version -o
/home/vzweije/tmp/ccgs0DVY.s
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../i486-linux-gnu/include"
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/i486-linux-gnu
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/backward
/usr/local/include
/usr/lib/gcc/i486-linux-gnu/4.1.2/include
/usr/include
End of search list.
GNU C++ version 4.1.2 20060814 (prerelease) (Debian 4.1.1-11)
(i486-linux-gnu)
compiled by GNU C version 4.1.2 20060814 (prerelease) (Debian
4.1.1-11).
GGC heuristics: --param ggc-min-expand=46 --param ggc-min-heapsize=31550
Compiler executable checksum: af253f4d4c50ecb6c5ed3e2466348eaf
test.cpp: In function 'void f(C*) [with C = int]':
test.cpp:8: instantiated from here
test.cpp:2: error: no matching function for call to 'f(int&)'
$
--
Summary: g++ fails to find dependent name in template from
instantiation context
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: debian-gcc at lists dot debian dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29229
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/29229] g++ fails to find dependent name in template from instantiation context
2006-09-25 22:48 [Bug c++/29229] New: g++ fails to find dependent name in template from instantiation context debian-gcc at lists dot debian dot org
@ 2006-09-25 22:54 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-09-25 22:54 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-09-25 22:54 -------
You are incorrect. This code is invalid because argument dependent namelookup
does not have an effect on fundumental types.
This sentence is where it goes wrong:
Name lookup (3.4, 3.4.2) does not distinguish between the different
contexts for the case of an instantiated instantiation.
14.6.4.2/1 says:
For the part of the lookup using unqualified name lookup (3.4.1), only function
declarations with external linkage from the template definition context are
found.
see the template definition context, so it does distinguish.
*** This bug has been marked as a duplicate of 2922 ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29229
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-09-25 22:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-25 22:48 [Bug c++/29229] New: g++ fails to find dependent name in template from instantiation context debian-gcc at lists dot debian dot org
2006-09-25 22:54 ` [Bug c++/29229] " pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).