This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Missing error for accessing an invalid type in a template specialisation?
- From: Jens Seidel <jensseidel at users dot sf dot net>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 11 Aug 2006 11:35:21 +0200
- Subject: Missing error for accessing an invalid type in a template specialisation?
Hi,
I wrote the following code which compiled fine (using -Wall -W -pedantic):
numeric_constants.h:
template<typename T>
class numeric_constants
{
};
template<>
class numeric_constants<float>
{
public:
static float nan() { return m_nan; }
private:
static const float m_nan;
};
numeric_constants.cpp:
#include "numeric_constants.h"
#include <cmath>
const float numeric_constants<float>::numeric_constants::m_nan = std::sqrt(-1);
Do you see the error? It should probably be
const float numeric_constants<float>::m_nan = std::sqrt(-1);
which compiles also fine with version 4.1.0.
Does anyone know why I do not get an error using the first definition?
Is this a bug in g++?
Please CC: me.
Jens