This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/55: Re: namespace bug using function templates
- To: gcc-gnats at sourceware dot cygnus dot com
- Subject: c++/55: Re: namespace bug using function templates
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Sun, 5 Mar 2000 11:26:29 +0100
- References: <51C9F3C392D0D111A15600A0C99E64A9011E24B3@localhost>
- Resent-Cc: gcc-prs at gcc dot gnu dot org
- Resent-Reply-To: gcc-gnats@gcc.gnu.org, "Martin v. Loewis" <martin@loewis.home.cs.tu-berlin.de>
>Number: 55
>Category: c++
>Synopsis: [not accepted] using-directives in templates
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Mar 05 02:46:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator: John Pedretti <pedretti@roguewave.com>
>Release: 2.95.2
>Organization:
>Environment:
>Description:
Original-Message-ID: <51C9F3C392D0D111A15600A0C99E64A9011E24B3@localhost>
Date: Fri, 19 Nov 1999 18:15:36 -0700
Hi,
The following code does not compile, apparently due to a bug in the way
function templates and namespaces are handled: class templates seem to work
properly.
Thanks,
John
===========================
John A. Pedretti, Rogue Wave Software, Inc.
(303) 545-3150 pedretti@roguewave.com
===========================
---------------------------------------
// foo.cc
namespace xx {
// declare function template inside namespace
template <class T>
void foo (T&) { }
}
// using namespace xx; // compiles if the using declaration is
moved to file scope
// declare function template inside global namespace
template <class T>
void bar (T& t) {
using namespace xx;
foo (t);
// xx::foo (t); // compiles if foo() is explicitly
qualified
}
template void bar<int> (const int&); // instantiate bar<int>
----------------------------------------
output of g++ -c -v foo.cc:
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/specs
gcc version 2.95.2 19991024 (release)
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/cpp -lang-c++ -v -D__GNUC__=2
-D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -D__ELF__ -Dunix -D__i386__
-Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux
-Asystem(posix) -D__EXCEPTIONS -Acpu(i386) -Amachine(i386) -Di386 -D__i386
-D__i386__ -Di686 -Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro
-D__pentiumpro__ foo.cc /tmp/cc72F7M1.ii
GNU CPP version 2.95.2 19991024 (release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../include/g++-3
/usr/local/include
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../i686-pc-linux-gnu/incl
ude
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/include
/usr/include
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/cc1plus /tmp/cc72F7M1.ii -quiet
-dumpbase foo.cc -version -o /tmp/ccMoxa8S.s
GNU C++ version 2.95.2 19991024 (release) (i686-pc-linux-gnu) compiled by
GNU C version 2.95.2 19991024 (release).
foo.cc:19: template-id `bar<int>' for `bar(const int &)' does not match any
template declaration
foo.cc:19: confused by earlier errors, bailing out
Compilation exited abnormally with code 1 at Fri Nov 19 20:16:49
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: