Your message dated Wed, 27 Sep 2006 03:53:05 +0200
with message-id <[EMAIL PROTECTED]>
and subject line [Bug c++/29229] g++ fails to find dependent name in template
from instantiation context (forwarded from pinskia at gcc dot gnu dot org)
has caused the attached Bug report to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere. Please contact me immediately.)
Debian bug tracking system administrator
(administrator, Debian Bugs database)
--- Begin Message ---
Package: g++-4.1
Version: 4.1.1-11
Severity: normal
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&)'
$
-- System Information:
Debian Release: testing/unstable
APT prefers oldstable
APT policy: (500, 'oldstable'), (500, 'testing'), (500, 'stable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/dash
Kernel: Linux 2.6.17.9
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Versions of packages g++-4.1 depends on:
ii gcc-4.1 4.1.1-11 The GNU C compiler
ii gcc-4.1-base 4.1.1-11 The GNU Compiler Collection (base
ii libc6 2.3.6.ds1-4 GNU C Library: Shared libraries
ii libstdc++6-4.1-dev 4.1.1-11 The GNU Standard C++ Library v3 (d
g++-4.1 recommends no packages.
-- no debconf information
--
Vincent Zweije <[EMAIL PROTECTED]> | "If you're flamed in a group you
<http://www.xs4all.nl/~zweije/> | don't read, does anybody get burnt?"
[Xhost should be taken out and shot] | -- Paul Tomblin on a.s.r.
signature.asc
Description: Digital signature
--- End Message ---
--- Begin Message ---
--- Begin Message ---
------- 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
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
You reported the bug, or are watching the reporter.
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
--- End Message ---
--- End Message ---