https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126740

            Bug ID: 126740
           Summary: Assert_Failure from mix of records, generics, and
                    -gnatn
           Product: gcc
           Version: 16.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: liam at liampwll dot com
                CC: dkm at gcc dot gnu.org
  Target Milestone: ---

Created attachment 65278
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65278&action=edit
reproducer

This was discovered while testing https://github.com/Prunt3D/prunt at different
optimisation levels. The underlying cause seems to be this bit of
Sem_Util.Abstract_Interface_List, however I haven't dug into it too much since
-gnatn doesn't improve performance where we need it anyway:

      elsif Ekind (Typ) = E_Record_Subtype then
         Nod := Type_Definition (Parent (Etype (Typ)));

Using the same behaviour as the E_Record_Subtype_With_Private case seems to fix
the issue, so I assume the comment there also applies to E_Record_Subtype.

Attached reproducer was pulled out of the codebase using a LLM armed with
adareducer since I could not figure out the pattern that causes this. It can be
compiled with `gcc -c -O2 -gnatn2 -gnatX motion.adb` or `-O3 -gnatn`.

Reply via email to