From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18580 invoked by alias); 19 Feb 2007 11:19:33 -0000 Received: (qmail 18523 invoked by uid 48); 19 Feb 2007 11:19:22 -0000 Date: Mon, 19 Feb 2007 11:19:00 -0000 Subject: [Bug c++/30857] New: accepts both explicit instantiation and explicit specialization, duplicate explicit instantiations, etc. X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "bkoz at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-02/txt/msg02181.txt.bz2 I thought g++ used to warn for this: template class foo { }; template<> class foo { }; template class foo; Where the error was something informative like "one may not explicitly specialize and explicitly instantiate" blah blah blah However, mainline currently does not do this. >>From 14.7 -5- No program shall explicitly instantiate any template more than once, both explicitly instantiate and explicitly specialize a template, or specialize a template more than once for a given set of template-arguments. An implementation is not required to diagnose a violation of this rule. So, this is not required by the standard. As a QoI issue, however, this would be beneficial. Here's why I wanted this: if one is doing API testing, and the API requires explicit specializations, than one possible negative test is to explicitly instantiate the required specialization and get an error. Otherwise, I suppose another neg test is to redefine the specialization. This is also not required to give an error, but current g++ does (redefinition error). Note also, no diagnostic for duplicate explicit instantiations: template class foo { }; template class foo; template class foo; Either of these or all may be a warning regressions (if my mind is not playing tricks on me.) I have not tested with other compilers, or previous g++ versions. Consistent behavior for all three cases would be appreciated. -- Summary: accepts both explicit instantiation and explicit specialization, duplicate explicit instantiations, etc. Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bkoz 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=30857