This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/41972] New: static reference as a template parameter fails
- From: "navinkumar+bugs at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Nov 2009 16:37:40 -0000
- Subject: [Bug c++/41972] New: static reference as a template parameter fails
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
in certain cases, GCC is unable to pass a static reference as a template
parameter.
SCENARIO 1 (SUCCEEDS):
//test1.cpp
template <typename T>
class X {
public:
static const T x;
};
template <typename T>
class Y {
public:
typedef X<T> wrapper_t;
template <const double& _test_>
class Foo { };
public:
typedef Foo<wrapper_t::x> type;
};
SCENARIO 2 (FAILS):
// test2.cpp
template <typename T>
class X {
public:
static const T x;
};
template <typename _ignore_>
class Y {
public:
typedef X<double> wrapper_t;
template <const double& _test_>
class Foo { };
public:
typedef Foo<wrapper_t::x> type;
};
template class Y<void>;
COMPILER ERROR FOR SCENARIO 2:
test2.cpp:14: error: ?X<double>::x? cannot appear in a constant-expression
test2.cpp:14: error: template argument 1 is invalid
--
Summary: static reference as a template parameter fails
Product: gcc
Version: 4.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: navinkumar+bugs at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41972