The following valid code snippet is rejected by mainline:

====================================
template<typename T> struct A
{
    static const T i = 1;
    char a[int(i)];
};
====================================

The error message is:
  bug1.cc:4: error: array bound is not an integer constant


Mark, this is similar to PR19826 which you already fixed, but with an
additional cast.

For the same reason the following testcase fails, too:

==================================
template<int> struct A {};

template<typename T> struct B
{
    static const T i = 2;
    A<int(i)> a;
};
==================================

bug2.cc:6: error: template argument 1 is invalid

Due to this problem the testcase in PR19297 still fails on mainline.

-- 
           Summary: [4.0 regression] Even more array bounds rejected as non-
                    constant in template...
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: rejects-valid, monitored
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: reichelt at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org,mark at codesourcery dot
                    com


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

Reply via email to