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]
Other format: [Raw text]

[Bug c++/17669] New: Scope mismatch


The following little "program", which used to work fine in gcc 3.3, results in a
scope error when compiled with gcc 3.4.  Replacing "char_traits" in the code
below with "std::char_traits" makes it compile without error.  So, it seems g++
doesn't use the "using namespace std" for char_traits, somehow.

I tried to just include the relevant parts of what showed up in the preprocessed
file, but then the problem went away, so this is unfortunately the most minimal
test I was able to get.  (ext/pod_char_traits.h is from libstdc++)

--- 8< ---
$ cat test.cpp
#include <ext/pod_char_traits.h>

using namespace std;
using namespace __gnu_cxx;

typedef character<unsigned short, int> WCHAR;

typedef basic_string<WCHAR, char_traits<WCHAR>, allocator<WCHAR> > WSTRING;

$ g++ -c test.cpp
test.cpp:8: error: `char_traits' was not declared in this scope
test.cpp:8: error: template argument 2 is invalid
test.cpp:8: error: expected unqualified-id before ',' token
test.cpp:8: error: expected init-declarator before '>' token
test.cpp:8: error: expected `,' or `;' before '>' token

$ diff -u test.cpp test2.cpp
--- test.cpp    2004-09-25 17:44:56.883215224 +0200
+++ test2.cpp   2004-09-25 17:49:47.230075792 +0200
@@ -5,4 +5,4 @@

 typedef character<unsigned short, int> WCHAR;

-typedef basic_string<WCHAR, char_traits<WCHAR>, allocator<WCHAR> > WSTRING;
+typedef basic_string<WCHAR, std::char_traits<WCHAR>, allocator<WCHAR> > WSTRING;

$ g++ -c test2.cpp
$
$ gcc -v
Reading specs from /usr/lib/gcc/i686-pc-linux-gnu/3.4.2/specs
Configured with: /var/tmp/portage/gcc-3.4.2-r1/work/gcc-3.4.2/configure
--enable-version-specific-runtime-libs --prefix=/usr
--bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.4
--includedir=/usr/lib/gcc/i686-pc-linux-gnu/3.4.2/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4/info
--with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/3.4.2/include/g++-v3
--host=i686-pc-linux-gnu --enable-nls --without-included-gettext
--enable-__cxa_atexit --enable-clocale=gnu --enable-shared --with-system-zlib
--disable-checking --disable-werror --disable-libunwind-exceptions --with-gnu-ld
--enable-threads=posix --disable-multilib --enable-languages=c,c++,objc,java
Thread model: posix
gcc version 3.4.2  (Gentoo Linux 3.4.2-r1, ssp-3.4.1-1, pie-8.7.6.5)

--- 8< ---

I'll attach the preprocessed file of test.cpp.

- Gerry

-- 
           Summary: Scope mismatch
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: trick at icculus dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17669


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