internal compiler error on certain variably sized 3d arrays
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc-10 (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
WSL2:
Ubuntu 20.04.2 LTS (GNU/Linux 5.4.72-
$ lsb_release -rd
Description: Ubuntu 20.04.2 LTS
Release: 20.04
$ apt-cache policy gcc-10
gcc-10:
Installed: 10.2.0-
Candidate: 10.2.0-
Version table:
*** 10.2.0-
500 http://
500 http://
100 /var/lib/
10-
500 http://
$ g++-10 -v
COLLECT_GCC=g++-10
COLLECT_
OFFLOAD_
OFFLOAD_
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (Ubuntu 10.2.0-
$ cat main.cpp
int main() {
int n;
bool arr[3][n][n] {};
if(arr[0][0][0]) {
// don't optimize this out
return 1;
}
}
$ g++-10 main.cpp
during RTL pass: expand
main.cpp: In function ‘int main()’:
main.cpp:3:7: internal compiler error: in make_decl_rtl, at varasm.c:1342
3 | bool arr[3][n][n] {};
| ^~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:/
The type of arr can be any primitive (could possibly include more types, didn't check). arr must be initialized with brackets. At least one of the first two dimensions of arr must be a constant, while the last dimension must be of variable length. I've repeated this behavior with versions 5.1.0, 6.4.0, 7.3.0, 9.2.0 on online compilers.
fixed in GCC 11 and newer versions