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++/34219] New: [4.3] gcc doesn't accept const members of variadic templates as const


template<typename T, T a, T... Params>
struct max
{
        static const T value = a > max<T, Params>::value ? a : max<T,
Params>::value;
};

template<typename T, T a, T b>
struct max<T, a, b>
{
        static const T value = a > b ? a : b;
};

static const int value1 = max< int, 1, 2>::value;
static const int value2 = max< int, 1, 3, 5>::value;



As the initialization for value1 is accepted as valid, that should be also the
case for value2. But g++ fails with the following error:

g++-4.3.0 -std=c++0x    -c -o test.o test.cpp
test.cpp: In instantiation of 'const int max<int, 1, 3, 5>::value':
test.cpp:14:   instantiated from here
test.cpp:4: error: 'max<int, 1, 3, 5>::value' cannot be initialized by a
non-constant expression when being declared


g++ Version is "gcc version 4.3.0 20071123 (experimental) (GCC)"


-- 
           Summary: [4.3] gcc doesn't accept const members of variadic
                    templates as const
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rbuergel at web dot de


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


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