From mboxrd@z Thu Jan 1 00:00:00 1970 From: bkoz@gnu.org To: gcc-gnats@gcc.gnu.org Cc: jason@redhat.com, mark@codesourcery.com Subject: c++/3239: template specializations and namespace issues Date: Mon, 18 Jun 2001 13:16:00 -0000 Message-id: <20010618200928.4094.qmail@sourceware.cygnus.com> X-SW-Source: 2001-06/msg00749.html List-Id: >Number: 3239 >Category: c++ >Synopsis: template specializations and namespace issues >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Mon Jun 18 13:16:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Benjamin Kosnik >Release: gcc-3.0, gcc CVS >Organization: >Environment: x86/linux, all >Description: Try compiling the following legal code: namespace std { template struct pair { typedef _T1 first_type; typedef _T2 second_type; _T1 first; _T2 second; //265. std::pair::pair() effects overly restrictive pair() : first(), second() {} pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {} template pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {} }; } bool global = false; template<> class std::pair { public: pair(const int&, const int&) { global = true; } }; And you'll get: %COMP.sh g++1.cc g++1.cc:29: specializing `class std::pair' in different namespace g++1.cc:6: from definition of `template struct std::pair' A particular C++ conformance suite uses this idiom throughout the testsuite. -benjamin >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: