[Bug c++/18354] New: expression "+1" not considered constant (as template parameter).
fsm at robots dot ox dot ac dot uk
gcc-bugzilla@gcc.gnu.org
Sun Nov 7 11:50:00 GMT 2004
Have class templated over "int". Compiler does not accept "+1" as template
parameter on the grounds that it is not a constant expression. Compiler accepts
both "-1" and "1".
This bug appears in: gcc version 4.0.0 20041107 (experimental)
gcc version 4.0.0 20041106 (experimental)
It did not appear in: gcc version 4.0.0 20040927 (experimental)
The following code reproduces the problem.
---------------------8<-------------------
template <int N>
struct X { };
void f()
{
X< 1> a;
X<-1> b;
X<+1> c; // <-- error here.
}
---------------------8<-------------------
$ g++ -c f.cxx
f.cxx: In function Âvoid f()Â:
f.cxx:8: error: Â1 is not a valid template argument for type Âint because it
is a non-constant expression
f.cxx:8: error: invalid type in declaration before Â;Â token
$ uname -a
Linux theseus 2.4.20-8smp #1 SMP Thu Mar 13 17:45:54 EST 2003 i686 i686 i386
GNU/Linux
$ g++ -v
Reading specs from /lvm/fred/gcc/cvs/install/lib/gcc/i686-pc-linux-gnu/4.0.0/specs
Configured with: ../gcc/configure --prefix=/lvm/fred/gcc/cvs/install
--enable-static --enable-shared --enable-languages=c,c++,f95
--with-mpfr=/lvm/fred/pkg/gmp/install
Thread model: posix
gcc version 4.0.0 20041107 (experimental)
--
Summary: expression "+1" not considered constant (as template
parameter).
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fsm at robots dot ox dot ac dot uk
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=18354
More information about the Gcc-bugs
mailing list