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++/11762] New: namespace aliasing ICE in warn_extern_redeclared_static


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: namespace aliasing ICE in warn_extern_redeclared_static
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bkoz at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: x86/linux

compiling the bit below gives:

%g++ -c namespace_issues_2.cc
namespace_issues_2.cc:36: error: conflicting types for `std'
<internal>:0: error: previous declaration as `std'
namespace_issues_2.cc:36: internal compiler error: tree check: expected
   var_decl, have namespace_decl in warn_extern_redeclared_static, at cp/decl.c
   :2827
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

but with icc gives:


%icc -c namespace_issues_2.cc
namespace_issues_2.cc(40): error: "std" has already been declared in the current
scope
  namespace std
            ^
 
namespace_issues_2.cc(40): error: "std" has already been declared in the current
scope
  namespace std
            ^
 
namespace_issues_2.cc(43): error: vector is not a template
       class vector<useless>
             ^
 
namespace_issues_2.cc(52): error: namespace "std" has no member "vector"
    std::vector<useless> v;
         ^
 
namespace_issues_2.cc(52): error: type name is not allowed
    std::vector<useless> v;
                ^
 
namespace_issues_2.cc(52): error: identifier "v" is undefined
    std::vector<useless> v;
                         ^
 
compilation aborted for namespace_issues_2.cc (code 2)

Anyway. Here goes the offending code.

// specialization error

#ifdef _GLIBCXX_DEBUG
  #define _GLIBCXX_NAMESPACE_STD __gnu_debug
#else
  #define _GLIBCXX_NAMESPACE_STD __gnu_release
#endif

namespace __gnu_debug
{
  template<typename _T>
  class vector
  {
  public:
    int foo() { return 5; }
  };
}

namespace __gnu_release
{
  template<typename _T>
  class vector
  {
  public:
    int foo() { return 6; }
  };
}

#if 0
namespace std
{
  using _GLIBCXX_NAMESPACE_STD::vector;
}
#else
// XXX Cannot re-open for specialization below.
namespace std = _GLIBCXX_NAMESPACE_STD;
#endif

struct useless { };

namespace std 
{
   template<>
     class vector<useless> 
     { 
     public:
       int foo() { return 7; }
     };
}

int main()
{
  std::vector<useless> v;
  int i = v.foo();

  return 0;
}


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