public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/66205] New: gnatbind generates invalid code when finalization is enabled in restricted runtime
@ 2015-05-19 14:44 simon at pushface dot org
  2015-06-11  7:34 ` [Bug ada/66205] " ramana at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: simon at pushface dot org @ 2015-05-19 14:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66205
           Summary: gnatbind generates invalid code when finalization is
                    enabled in restricted runtime
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: simon at pushface dot org
  Target Milestone: ---

Created attachment 35567
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35567&action=edit
Patch to gcc/ada/bindgen.adb

This is on 4.9.1 compiled for arm-eabi on Mac OS X Mavericks (Darwin 13).
Please note that the same problem occurs with 5.1.0.

package System has

pragma Profile (Ravenscar);
pragma Restrictions (No_Enumeration_Maps);
pragma Restrictions (No_Exception_Propagation);
pragma Restrictions (No_Recursion);

and the result of a gprbuild is

gprbuild -p -P testbed
gprbind testbed.bexch
arm-eabi-gnatbind testbed.ali
arm-eabi-gcc -c b__testbed.adb
b__testbed.adb:31:14: "Is_Elaborated" is undefined (more references follow)
gprbind: compilation of binder generated file failed
gprbuild: unable to bind testbed.adb

which happens because bindgen.adb has at :2497

         if not Suppress_Standard_Library_On_Target then
            WBI ("   Is_Elaborated : Boolean := False;");
         end if;

but at :408 in the generation of adafinal

      if not CodePeer_Mode then
         WBI ("      if not Is_Elaborated then");
         WBI ("         return;");
         WBI ("      end if;");
         WBI ("      Is_Elaborated := False;");
      end if;

I’ve worked out a patch for this, but I’m confused about when to use
Suppress_Standard_Library_On_Target vs Configurable_Run_Time_On_Target vs
Configurable_Run_Time_Mode to determine that adafinal will never actually be
called & hence needn’t do anything.

Not sure whether __gnat_initialize, __gnat_finalize are expected (they aren’t
in the AdaCore arm-eabi libraries), so I’ve suppressed them too.
>From gcc-bugs-return-486683-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue May 19 14:56:13 2015
Return-Path: <gcc-bugs-return-486683-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 50324 invoked by alias); 19 May 2015 14:56:12 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 49912 invoked by uid 48); 19 May 2015 14:56:07 -0000
From: "gil.hur at sf dot snu.ac.kr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/65752] Too strong optimizations int -> pointer casts
Date: Tue, 19 May 2015 14:56:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: 4.9.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: gil.hur at sf dot snu.ac.kr
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Resolution:
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:
Message-ID: <bug-65752-4-2aW1vzFm2c@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65752-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65752-4@http.gcc.gnu.org/bugzilla/>
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-05/txt/msg01523.txt.bz2
Content-length: 1794

https://gcc.gnu.org/bugzilla/show_bug.cgi?ide752

--- Comment #21 from Chung-Kil Hur <gil.hur at sf dot snu.ac.kr> ---
(In reply to Marek Polacek from comment #20)
> (In reply to Chung-Kil Hur from comment #19)
> > (In reply to rguenther@suse.de from comment #18)
> > > On Tue, 19 May 2015, gil.hur at sf dot snu.ac.kr wrote:
> > >
> > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?ide752
> > > >
> > > > --- Comment #17 from Chung-Kil Hur <gil.hur at sf dot snu.ac.kr> ---
> > > > Hi Richard,
> > > >
> > > > I modified the example further.
> > > >
> > > > #include <stdio.h>
> > > >
> > > > int main() {
> > > >   int x = 0;
> > > >   uintptr_t xp = (uintptr_t) &x;
> > > >   uintptr_t i, j;
> > > >
> > > >   for (i = 0; i < xp; i++) { }
> > > >   j = i;
> > > >   /* The following "if" statement is never executed because j == xp */
> > > >   if (j != xp) {
> > > >     printf("hello\n");
> > > >     j = xp;
> > > >   }
> > >
> > > Here j is always xp and thus ...
> > >
> >
> > Why is "j" always "xp"?
> > Since "hello" is not printed, "j = xp;" is not executed.
>
> Because that "if (j != xp)" guarantees it.

OK. here is another modification.

#include <stdio.h>

int main() {
  int x = 0;
  uintptr_t xp = (uintptr_t) &x;
  uintptr_t i, j;

  for (i = 0; i < xp; i++) { }
  j = i;

  *(int*)j = 15;

  /* The following "if" statement is never executed because j == xp */
  if (j != xp) {
    printf("hello\n");
    j = xp;
  }

  *(int*)((xp+i)-j) = 15;

  printf("%d\n", x);
}

This program just prints "0".

So we know that "*(int*)j = 15;" is not executed and thus "j == xp" is not
true.

Then, can the following statement change "j" even if the printf is not
executed?

if (j != xp) {
   printf("hello\n");
   j = xp;
}

If not, how can "j == xp" suddenly hold?


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-06-11 16:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-19 14:44 [Bug ada/66205] New: gnatbind generates invalid code when finalization is enabled in restricted runtime simon at pushface dot org
2015-06-11  7:34 ` [Bug ada/66205] " ramana at gcc dot gnu.org
2015-06-11 10:33 ` ebotcazou at gcc dot gnu.org
2015-06-11 15:59 ` simon at pushface dot org
2015-06-11 16:04   ` Arnaud Charlet
2015-06-11 16:04 ` charlet at adacore dot com
2015-06-11 16:15 ` simon at pushface dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).