aboutsummaryrefslogtreecommitdiff
path: root/gcc/d
diff options
context:
space:
mode:
authorJustin Squirek <squirek@adacore.com>2022-02-10 23:03:00 +0000
committerPierre-Marie de Rodat <derodat@adacore.com>2022-05-16 08:42:06 +0000
commitb32b51902cd97e3a8a2eede10a847688c5f15cde (patch)
treebac4fc6e0f6c81e79a4bd72b656f5e145aa73a50 /gcc/d
parent26bbf0e5da9af096eeddc2a79e1e0da9673b6bd2 (diff)
downloadgcc-b32b51902cd97e3a8a2eede10a847688c5f15cde.zip
gcc-b32b51902cd97e3a8a2eede10a847688c5f15cde.tar.gz
gcc-b32b51902cd97e3a8a2eede10a847688c5f15cde.tar.bz2
[Ada] Type invariant or postcondition may cause uninitialized memory reads
This patch corrects an error in the compiler whereby a function requiring the generation of a postconditions procedure may cause an uninitialized memory read when the return type Has_Unconstrained_Elements or is an unconstrained array. The error occurs because evaluation of postconditions happens within the "at end" handler when the temporary result object may go out of scope. The patch modifies expansion in the above cases to evaluate postconditions at the point of return instead - in order to guarantee the result object is valid. Note that these changes have the side effect of introducing a semantic bug such that functions returning types with unconstrained elements will have their postconditions/return type invariants evaluated before finalization. Work is currently being done to introduce wrappers which will solve this problem and remove technical debt in this area. gcc/ada/ * exp_ch7.adb (Build_Finalizer): Disable late evaluation of postconditions for functions returning types which where Has_Unconstrained_Elements is true or are unconstrained arrays.
Diffstat (limited to 'gcc/d')
0 files changed, 0 insertions, 0 deletions