This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

namespace bug using function templates


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






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]