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++/47897] New: [C++0x] static const member variable is not constant expression


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47897

           Summary: [C++0x] static const member variable is not constant
                    expression
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: flast@flast.jp


GCC4.6.0(with C++0x mode) reject static const member variable depending
template parameter type.

---- testcase.C ----
template < typename T, T N >
struct S
{
    static const T value = N;
    typedef S< T, value + 1 > next;
};
--------------------

It seems caused by r170488 (git: cfa61f8435164f3205d70c7e1c5038b2d881aa1d).

In other case, GCC accepts codes.
For example:
---- testcase.C (accepted) ----
template < int N >
struct S
{
    static const int value = N;
    typedef S< value + 1 > next;
};
-------------------------------

Another case:
---- testcase.C (accepted) ----
template < typename T, T N >
struct S
{
    static constexpr T value = N;
    typedef S< T, value + 1 > next;
};
-------------------------------


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