This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/14007] New: Incorrect use of const partial specialization for reference template argument
- From: "austern at apple dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Feb 2004 19:57:16 -0000
- Subject: [Bug c++/14007] New: Incorrect use of const partial specialization for reference template argument
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Consider the following test program:
#include <stdio.h>
template <class T> struct X { enum { val = 0 }; };
template <class T> struct X<const T> { enum { val = 1 }; };
int main() {
printf("%d\n", X<int&>::val);
}
The value printed is "1". That is, the 3.x compiler (tested with 3.1, 3.3, and mainline) thinks that
X<int&> refers to the X<const T> partial specialization rather than to the primary template.
I believe that this is wrong. The partial specialization should only be used for a type that has a
top-level const qualifier, and references are not cv-qualified. (8.3.2, paragraph 1).
This is a regression from 2.95.
--
Summary: Incorrect use of const partial specialization for
reference template argument
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: austern at apple dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: powerpc-apple-darwin7.2.0
GCC host triplet: powerpc-apple-darwin7.2.0
GCC target triplet: powerpc-apple-darwin7.2.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14007