]> git.ipfire.org Git - thirdparty/gcc.git/commit
Ada: Fix segfault on mutually recursive record type declarations
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 27 Oct 2025 08:53:57 +0000 (09:53 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Mon, 27 Oct 2025 08:55:48 +0000 (09:55 +0100)
commit476cfea758fa1240b5ae8bc25ac8eb0de06fff89
tree728cbe75f1c48e54e5723781f3a0a04add5e4ed9
parent5c1f506d4515864bd38f95f82dff624318327788
Ada: Fix segfault on mutually recursive record type declarations

This was reported a long time ago and is again a fairly pathological case,
but it turns out to be unfixable with the current model of type freezing
in GNAT (which is the second one suggested in the AARM 13.14(19.i) clause).

The code is legal but, as the declaration of any object of the types will
exhaust the heap and eventually raise Storage_Error, it is totally useless.

The patch contains a small cleanup in a related area as well as the addition
of a commented assertion in gigi, so that the compiler shuts down properly.

gcc/ada/
PR ada/15800
* freeze.adb (Freeze_Entity.Freeze_Record_Type): Small cleanup
in code and comments.
* gcc-interface/utils.cc (create_field_decl): Assert that the type
of the field is frozen at this point.
gcc/ada/freeze.adb
gcc/ada/gcc-interface/utils.cc