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

            Bug ID: 90804
           Summary: function declaration cannot have variably modified
                    type
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhonghao at pku dot org.cn
  Target Milestone: ---

My gcc is 10.0.0, and the code is:

int a(int b) {int (*c(void))[b];**c() = 2;}

gcc accepts the code, but clang, icc, and msvc all reject it:

clang:
source>:1:21: error: function declaration cannot have variably modified type

int a(int b) {int (*c(void))[b];**c() = 2;}

                    ^

1 error generated.

Compiler returned: 1

icc:
<source>(1): error: an entity with linkage cannot have a type involving a
variable length array

  int a(int b) {int (*c(void))[b];**c() = 2;}

                      ^

compilation aborted for <source> (code 2)

Compiler returned: 2

msvc:

example.cpp

<source>(1): error C2131: expression did not evaluate to a constant

<source>(1): note: failure was caused by a read of a variable outside its
lifetime

<source>(1): note: see usage of 'b'

Compiler returned: 2

Reply via email to