[Bug ada/42236] New: ICE for dispatching call involving explicit dereference

2009-12-01 Thread fweimer at bfk dot de
The following program triggers a bug box.

gcc-4.4 -c t.adb
+===GNAT BUG DETECTED==+
| 4.4.2 (x86_64-pc-linux-gnu) Assert_Failure sinfo.adb:1149|
| Error detected at t.adb:49:13|
| Please submit a bug report; see http://gcc.gnu.org/bugs.html.|
| 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 gcc-4.4 or gnatmake command that you entered.  |
| Also include sources listed below in gnatchop format |
| (concatenated together with no headers between files).   |
+==+

The bug is also present in GCC 4.3.  It would be nice if there was
some sort of workaround; I need this to adjust code to the changed
semantics of limited return types in Ada 2005.

In GCC 4.3, the crash happens at this point in
sem_disp.check_dispatching_call:

539   else
540  Func :=
541Entity (Name
542  (Original_Node
543(Expression (Original_Node (Actual);
544   end if;

GDB reports:

(gdb) print pn(actual)
N_Explicit_Dereference (Node_Id=1864) (source,analyzed)
 Sloc = 8744  t.adb:49:52
 Etype = N_Defining_Identifier "transaction" (Entity_Id=1670)
 Prefix = N_Identifier "R168b" (Node_Id=1863)
$7 = void
(gdb) print pn(original_node(actual))
N_Explicit_Dereference (Node_Id=1864) (source,analyzed)
 Sloc = 8744  t.adb:49:52
 Etype = N_Defining_Identifier "transaction" (Entity_Id=1670)
 Prefix = N_Identifier "R168b" (Node_Id=1863)
$8 = void

with Ada.Finalization;

procedure T is

   package Transactions is
  type Transaction is limited private;
  function No_Transaction return access Transaction;

   private
  pragma Inline (No_Transaction);

  type Transaction is new Ada.Finalization.Limited_Controlled with record
 Handle : Natural := 0;
  end record;
   end;

   package body Transactions is
  No_Txn : aliased Transaction;

  function No_Transaction return access Transaction is
  begin
 return No_Txn'Access;
  end No_Transaction;
   end Transactions;

   package Databases is
  type Database is limited private;
  procedure Open
(D : in out Database;
 T : Transactions.Transaction);
   private
  type Database is new Ada.Finalization.Limited_Controlled with record
 Handle : Natural := 0;
  end record;
   end Databases;

   package body Databases is
  procedure Open
(D : in out Database;
 T : Transactions.Transaction) is
  begin
 null;
  end;
   end;

   DB : Databases.Database;

begin
   Databases.Open (DB, Transactions.No_Transaction.all);
end T;


-- 
   Summary: ICE for dispatching call involving explicit dereference
   Product: gcc
   Version: 4.4.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fweimer at bfk dot de
 GCC build triplet: x86_64-linux-gnu
  GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42236



[Bug ada/42239] New: Pragma Inline_Always removes function calls with side effects

2009-12-01 Thread fweimer at bfk dot de
The following program (to be run through gnatchop) is supposed
to exit with status 17.  It exits with status 0 instead.  Inspecting
the generated machine code reveals that the call to Close is
not emitted:

 <_ada_u>:
   0:   55  push   %rbp
   1:   48 89 e5mov%rsp,%rbp
   4:   c9  leaveq
   5:   c3  retq

(This is at -O0, -O2 is similar.  Sorry for the misnomer; the test suite
which caught this had an actual close call there; I've changed it to exit
here for easier testing.)

This bug has also been observed with GCC 4.3.4.

with Interfaces.C; use Interfaces.C;

package POSIX_Base is
   function C_Close (FD : int) return int;
   pragma Import (C, C_Close, "exit");
end POSIX_Base;

with Interfaces.C; use Interfaces.C;

package POSIX is
   procedure Close (FD : int);

private
   pragma Inline_Always (Close);
end POSIX;

with POSIX_Base; use POSIX_Base;

package body POSIX is
   procedure Close (FD : int) is
  Status : constant int := C_Close (FD);
  pragma Unreferenced (Status);
   begin
  null;
   end;
end POSIX;

with POSIX; use POSIX;

procedure U is
begin
   Close (17);
end;


-- 
   Summary: Pragma Inline_Always removes function calls with side
effects
   Product: gcc
   Version: 4.4.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
AssignedTo: unassigned at gcc dot gnu dot org
    ReportedBy: fweimer at bfk dot de
 GCC build triplet: x86_64-pc-linux-gnu
  GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42239