https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89239

            Bug ID: 89239
           Summary: gcc claims that this expression is not constexpr
           Product: gcc
           Version: 8.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: n.eugene536 at gmail dot com
  Target Milestone: ---

Can't compile the following code:

enum E { e };

constexpr bool arr[1][1] = {{true}};

template<E x, E y>
void check() { 
    static_assert(arr[x][y], ""); 
}

int main() { 
    check<e, e>(); 
}

gcc says:
a.cpp: In instantiation of ‘void check() [with A x = (A)0; A y = (A)0]’:
a.cpp:11:17:   required from here
a.cpp:7:28: error: non-constant condition for static assertion
     static_assert(sz[x][y] == false, "");
a.cpp:7:28: error: accessing value of ‘sz’ through a ‘const bool’ glvalue in a
constant expression

g++ --version: 
g++ (Ubuntu 8.2.0-7ubuntu1) 8.2.0

Reply via email to