Bug 96980 - unimplemented of variably-modified type
Summary: unimplemented of variably-modified type
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks: C++VLA
  Show dependency tree / graph
 
Reported: 2020-09-08 12:51 UTC by tangyixuan
Modified: 2024-06-22 18:44 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tangyixuan 2020-09-08 12:51:13 UTC
Hi, the following code is not compiled by g++ but is compiled by clang.

$ cat s.cpp

int main (){
        int a=2, b=3;
        int A[a][b];
        auto B =[&](){
                int c=1, d=2;
                int C = A[c][d];
        };
        B();
}


$ clang++ -c s.cpp
success.

$ g++ -c s.cpp
s.cpp: In lambda function:
s.cpp:6:25: sorry, unimplemented: capture of variably-modified type ‘int [a][b]’ that is not an N3639 array of runtime bound
    6 |                 int C = A[c][d];
      |                         ^
s.cpp:6:25: note: because the array element type ‘int [b]’ has variable size

$ g++ -v
Using built-in specs.
COLLECT_GCC=/usr/local/gcc-20200823/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/gcc-20200823/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-11-20200823/configure --prefix=/usr/local/gcc-20200823 --enable-checking=release --enable-languages=c,c++ --disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20200823 (experimental) (GCC)
Comment 1 Jonathan Wakely 2020-09-08 14:49:15 UTC
This is not valid C++, that's why GCC doesn't accept it.