Repository navigation
Array designators in GNU VLA initializers lose values or crash the compiler #556
lexx42xxel
started this conversation in
Issue Triage - Compilation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Issue Summary
In GNU C++ mode an initializer for a variable-length array is accepted, but an array designator in it is lowered as if the array had a constant size: the designated value is silently lost, rows are written past the end of the array, or the front end hits an internal error (compile with
-DCRASH; alsoint a[3][n] = {{[1] = 7}};).Reproducing Source Code
Command-line Options
eccp --c++11 --g++ t.cpp -o t && ./t
Type of Issue
[Front End] I do not care but this code CRASHES the compiler.
Additional Details
Version: EDG C/C++ front end 7.0, main at commit
6a6c7f2d6bd8027f1b0c90877b4ba222fbff6642(2026-11-15).Actual output:
Expected: A diagnostic, as g++ gives (g++ 15: "sorry, unimplemented: non-trivial designated
initializers not supported"), or correct code.
Designated-initializer lowering assumes a constant array size. Proposed fix: diagnose array
designators for VLAs (designators for constant-size arrays, field designators and arrays of
pointers to VLAs remain accepted).
The program exits nonzero when the bug is present. A fix with a regression
test is ready (branch
fix/vla-array-designator-diagnostic); a PR will reference this issue.Reproducing (Standard) Configuration(s)
linux-gcc-debug
Reproducing (Non-standard) Configuration
No response
I acknowledge that:
LICENSE.txtfile in my.zipor.tar.gzupload. If I included aLICENSE.txtfile, any tests created using the reproducing source code will be governed by the terms of the license I provided instead.All reactions