From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27051 invoked by alias); 23 Mar 2015 17:04:59 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 24765 invoked by uid 48); 23 Mar 2015 17:04:56 -0000 From: "demoonlit at panathenaia dot halfmoon.jp" To: gcc-bugs@gcc.gnu.org Subject: [Bug ada/65524] gnatbind generates decrementing the unexisting elab-counter into finalize_library Date: Mon, 23 Mar 2015 17:56:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ada X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: demoonlit at panathenaia dot halfmoon.jp X-Bugzilla-Status: WAITING X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg02430.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65524 --- Comment #2 from yuta tomino --- Created attachment 35115 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35115&action=edit example I found the way of reproducing. A tiny change of a-tags.ads is necessary. Insert "is null" into Ada.Tags.Register_Tag to suppress the elaboration. (Is there a pragma or restriction for this purpose?) Note, Unregister_Tag is unrelated. And, make a package as Pure or Preelaborate. Add a tagged type. So the package would have _finalize_spec without _elabs. (The direct cause of this case is the asymmetry that _elabs is not generated if Register_Tag is null, against that, _fialize_spec is always generated even if Unregister_Tag is null. Register/Unregister_XXX are sometimes suppressed in parts of customized runtimes. My customized runtime satisfies the conditions about this time. However, the way is only example for reproducing. I think another approach is possibility because Build_Finalizer in exp_ch7.adb is very complex...) And then, prepare a main subprogram using the package. Compile and gnatbind. See b~main.adb. The log of compiling the attached example: % gnatmake -a -gnatp -g main gnatbind -x main.ali gnatlink main.ali -g b~main.adb:31:10: "E81" is undefined (more references follow) b~main.adb:34:07: "E05" is undefined (more references follow) gnatmake: *** link failed. By the way, sorry, I realized that my first patch is not proper fix. For multiple-elaboration, an elaboration-counter should be generated and incremented in adainit when a _finalize_spec/body is existing, even if _elabs is not existing. Thanks.