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]

g++: bug in namespaces?


I suppose the following file should compile.
Explicitly importing the variable definition with st::int_type works
though. 

Peter Schmid 

cat tn1.C

namespace st {
    template <class T> struct Class { typedef T my_type; };
    typedef Class<int>::my_type int_type;
}

inline int ns_foo (typename st::int_type t) {
    using namespace st;
    int_type i = 2 ;
//      st::int_type i = 2;
    return i+t; 
}
namespace my_st=st; 

int t() {
    ns_foo(1);
    return 0;
}
     
int main() {
    t();
    return 0;
}

g++ -v -o tn1 tn1.C -W -Wall
Reading specs from /usr/lib/gcc-lib/i386-pc-linux-gnulibc1/egcs-2.91.33/specs
gcc version egcs-2.91.33 19980525 (gcc2 ss-980502 experimental)
 /usr/lib/gcc-lib/i386-pc-linux-gnulibc1/egcs-2.91.33/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -W -Wall 
-Di386 -Asystem(unix) -Acpu(i386) -Amachine(i386) -D__i386__ -Asystem(unix) -Acpu(i386) -Amachine(i386) tn1.C /dos/tmp/cca00106.ii
GNU CPP version egcs-2.91.33 19980525 (gcc2 ss-980502 experimental) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/g++
 /usr/local/include
 /usr/i386-pc-linux-gnulibc1/include
 /usr/lib/gcc-lib/i386-pc-linux-gnulibc1/egcs-2.91.33/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i386-pc-linux-gnulibc1/egcs-2.91.33/cc1plus
/dos/tmp/cca00106.ii -quiet -dumpbase tn1.cc -W -Wall -version -o
/dos/tmp/cca00106.s 
GNU C++ version egcs-2.91.33 19980525 (gcc2 ss-980502 experimental)
(i386-pc-linux-gnulibc1) compiled by GNU C version egcs-2.91.33
19980525 (gcc2 ss-980502 experimental). 
tn1.C: In function `int ns_foo(int_type)':
tn1.C:7: parse error before `using'
tn1.C:8: `int_type' undeclared (first use this function)
tn1.C:8: (Each undeclared identifier is reported only once
tn1.C:8: for each function it appears in.)
tn1.C:10: `i' undeclared (first use this function)
tn1.C:11: warning: control reaches end of non-void function `ns_foo(int_type)'



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