https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106698
Bug ID: 106698 Summary: `-O2 -flto` cause linker warning Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada Assignee: unassigned at gcc dot gnu.org Reporter: jesper.quorning at gmail dot com Target Milestone: --- Created attachment 53484 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53484&action=edit Minimal reproducer Building `program.ada` with optimisation -O2 or above: % gnatmake -O2 -flto main.adb Causes linker warning: ``` gcc -c -O2 -flto main.adb gcc -c -O2 -flto test.adb gnatbind -x main.ali gnatlink main.ali -O2 -flto test.adb: In function 'test__assign': test.adb:6:21: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 6 | The_Array (1) := AAAAA_Enum; | ^ test.ads:11:4: note: at offset -9223372036854775808 into destination object 'F' of size 4 11 | The_Array : T_Array; | ^ ``` The program is essentially: type First_Enum is (AAAAA_Enum); subtype Second_Enum is First_Enum; type T_Array is array (Integer range -1 .. 2) of Second_Enum; -- Change 'First to something >= 0 and the warning disappears. -- Using the First_Enum instead of Second_Enum and the warning disappears. GNATMAKE 12.1.0 - cause warning GNATMAKE 11.2.0 - cause warning GNATMAKE 10.3.0 - cause no warning