https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85760
Bug ID: 85760 Summary: Using generic function to initialize a type created by a generic package crashes GNAT Product: gcc Version: 7.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada Assignee: unassigned at gcc dot gnu.org Reporter: jhb.chat at gmail dot com Target Milestone: --- Host: Windows 10 msys2 mingw64 Target: x86_64-w64-mingw32 given a package, Wrappers.ads ************************************************ generic type Element_Type is limited private; package Wrappers is type Wrapper is tagged limited private; -- Causes GNAT crash when used to initialize a wrapper -- Happens in GNAT GPL 2017, FSF GNAT 7.2, and FSF GNAT 7.3 generic with function Constructor(Value : Element_Type) return Element_Type; function Make(Value : Element_Type) return Wrapper; private type Wrapper is tagged limited null record; end Wrappers; ************************************************ wrappers.adb ************************************************ package body Wrappers is function Make(Value : Element_Type) return Wrapper is begin return (others => <>); end Make; end Wrappers; ************************************************ implemented in main.adb ************************************************ with Ada.Text_IO; use Ada.Text_IO; with Wrappers; procedure Main is package Int_Wrappers is new Wrappers(Integer); function Make(Value : Integer) return Integer is (Value); function Make is new Int_Wrappers.Make (Constructor => Make); v : Int_Wrappers.Wrapper := Make(50); begin null; end Main; ************************************************ outputs: ************************************************ $ gprbuild default.gpr gcc -c -g -gnatn -gnato -gnatE -fstack-check -gnat12 -O3 -g main.adb gprbuild: *** compilation phase failed ************************************************ Side Note: Compiling in GNAT GPL 2017 outputs: ************************************************ Compile [Ada] main.adb +===========================GNAT BUG DETECTED==============================+ | GPL 2017 (20170515-63) (i686-pc-mingw32) Program_Error EXCEPTION_ACCESS_VIOLATION| | Error detected at main.adb:11:4 | | Please submit a bug report by email to rep...@adacore.com. | | GAP members can alternatively use GNAT Tracker: | | http://www.adacore.com/ section 'send a report'. | | See gnatinfo.txt for full info on procedure for submitting 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. | | Use plain ASCII or MIME attachment(s). | +==========================================================================+ 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). src\main.adb src\wrappers.ads compilation abandoned gprbuild: *** compilation phase failed ************************************************ changing: v : Int_Wrappers.Wrapper := Make(50); to: v : Int_Wrappers.Wrapper; allows compilation. using "gcc -v -save-temps all-your-options source-file" as instructed only creates an empty main.s file (attached). I attached a test case in a .zip