https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99095
Bug ID: 99095 Summary: Unconstrained array of limited records results in a bounds bug. Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada Assignee: unassigned at gcc dot gnu.org Reporter: rodakay5 at gmail dot com Target Milestone: --- Created attachment 50181 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50181&action=edit Contains 2 minimal test procedures. $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/usr/include/dlang/gdc Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 10.2.0 (GCC) $ gnatmake -vh test_bug_box.adb GNATMAKE 10.2.0 Copyright (C) 1992-2020, Free Software Foundation, Inc. "test_bug_box.ali" being checked ... -> "test_bug_box.ali" missing. gcc -c test_bug_box.adb +===========================GNAT BUG DETECTED==============================+ | 10.2.0 (x86_64-pc-linux-gnu) Storage_Error stack overflow or erroneous memory access| | Error detected at test_bug_box.adb:16:4 | | Please submit a bug report; see https://gcc.gnu.org/bugs/ . | | Use a subject line meaningful to you and us to track the bug. | | Include the entire contents of this bug box in the report. | | Include the exact command that you entered. | | Also include sources listed below. | +==========================================================================+ Please include these source files with error report Note that list may not be accurate in some cases, so please double check that the problem can still be reproduced with the set of files listed. Consider also -gnatd.n switch (see debug.adb). test_bug_box.adb compilation abandoned End of compilation gnatmake: "test_bug_box.adb" compilation error The attached file contains 2 test procedures ... 'Test_Bug_Box' contains code which results in a gnat bug box. The procedure itself prints out no output. 'Test_Buggy_Bounds' builds without a bug box. The expected output is ... a) First => 1 a) Last => 2 b) First => 1 b) Last => 2 The actual output is ... a) First => 1 a) Last =>-1171747055 b) First => 1326201608 b) Last => 32767 The 'a) First' value is always 1. The others values are random. The code contains some commented out lines which I hope are helpful. The problem appears to have been introduced in 'GCC version 10.1.0'. The problem does not occur in GCC 9.3.0 or lower. A (naive) guess might be that the secondary stack pointer becomes corrupted or is wrongly positioned. Regards.