This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/41972] New: static reference as a template parameter fails


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]