aboutsummaryrefslogtreecommitdiff
path: root/libquadmath/math/sinq_kernel.c
diff options
context:
space:
mode:
authorJavier Miranda <miranda@adacore.com>2018-07-17 08:06:09 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-07-17 08:06:09 +0000
commite8427749a9c5ad6ec2c0653dcc4edea5b41efc31 (patch)
tree5d54cbc1fd07e8494974476978436cde9c5428c8 /libquadmath/math/sinq_kernel.c
parent5ffc5c55091ba8a2d5290f7a0851c5d484e8ac85 (diff)
downloadgcc-e8427749a9c5ad6ec2c0653dcc4edea5b41efc31.zip
gcc-e8427749a9c5ad6ec2c0653dcc4edea5b41efc31.tar.gz
gcc-e8427749a9c5ad6ec2c0653dcc4edea5b41efc31.tar.bz2
[Ada] Secondary stack leak in loop iterator
When the evaluation of the loop iterator invokes a function whose result relies on the secondary stack the compiler does not generate code to release the consumed memory as soon as the loop terminates. After this patch the following test works fine. with Text_IO; use Text_IO; pragma Warnings (Off); with System.Secondary_Stack; pragma Warnings (On); procedure Sec_Stack_Leak is function F (X : String) return Integer is begin return 10; end F; function G (X : Integer) return String is begin return (1 .. X => 'x'); end G; procedure Info is new System.Secondary_Stack.Ss_Info (Put_Line); procedure Nest is begin for I in Integer range 1 .. 100 loop for J in Integer range 1 .. F (G (10_000)) loop null; end loop; Info; end loop; Info; end Nest; begin Info; Nest; Info; end Sec_Stack_Leak; Commands: gnatmake -q sec_stack_leak.adb sec_stack_leak | grep "Current allocated space :" | uniq Output: Current allocated space : 0 bytes 2018-07-17 Javier Miranda <miranda@adacore.com> gcc/ada/ * sem_ch5.adb (Has_Call_Using_Secondary_Stack): Moved to library level to reuse it. (Analyze_Loop_Statement): Wrap the loop in a block when the evaluation of the loop iterator relies on the secondary stack. From-SVN: r262774
Diffstat (limited to 'libquadmath/math/sinq_kernel.c')
0 files changed, 0 insertions, 0 deletions