aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppdefault.h
diff options
context:
space:
mode:
authorGary Dismukes <dismukes@adacore.com>2025-03-08 01:05:35 +0000
committerEric Botcazou <ebotcazou@adacore.com>2025-06-09 10:22:52 +0200
commitf59c4d4a6a30c655afb53236eee2bda9e2d2cbb2 (patch)
treee2e747f01822ef2f7f9f34df66687a23a4912825 /gcc/cppdefault.h
parente68026cd01d87a89d52c74238d4c1bff8764f9fc (diff)
downloadgcc-f59c4d4a6a30c655afb53236eee2bda9e2d2cbb2.zip
gcc-f59c4d4a6a30c655afb53236eee2bda9e2d2cbb2.tar.gz
gcc-f59c4d4a6a30c655afb53236eee2bda9e2d2cbb2.tar.bz2
ada: Missing discriminant check on assignment of Bounded_Vector aggregate
When a container aggregate for a Bounded_Vector type involves an iterated association that is assigned to a vector object whose capacity (as defined by the Capacity discriminant) is less than the number of elements of the aggregate, Constraint_Error should be raised due to failing a discriminant check on the assignment. But the compiler fails to do proper expansion, plus omits the check, and instead creates a temporary whose capacity is bounded by that of the target vector of the assignment. It attempts to assign all elements of the aggregate to the temporary, resulting in a failure on a call to the Replace_Element operation that assigns past the length of the temporary vector (which can result in a Storage_Error due to a segment violation). This is fixed by ensuring that the temporary object is declared with an unconstrained base subtype rather than the assignment target's constrained subtype. gcc/ada/ChangeLog: * exp_aggr.adb (Expand_Container_Aggregate): Use the Base_Type of the subtype provided by the context as the subtype of the temporary object initialized by the aggregate.
Diffstat (limited to 'gcc/cppdefault.h')
0 files changed, 0 insertions, 0 deletions