[Bug ada/101970] New: [11 regression] ICE on 'Enum_Rep for the enum that filled its representation range

2021-08-18 Thread demoonlit at panathenaia dot halfmoon.jp via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101970

Bug ID: 101970
   Summary: [11 regression] ICE on 'Enum_Rep for the enum that
filled its representation range
   Product: gcc
   Version: 11.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: demoonlit at panathenaia dot halfmoon.jp
  Target Milestone: ---

Created attachment 51322
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51322=edit
full test code

Perhaps this is a regression by fixing the bug 101094.

'Enum_Rep causes GNAT bug Box, with the enum type containing the number of
elements to fill just its (signed?) representation range.

Thanks.

 test code 

Here is the abbreviated test code.
The full code is attached.

with Ada.Integer_Text_IO;
with Ada.Text_IO;
procedure test_enumrep2 is
   type T is (E80, ..., E00, ..., E7F); -- 256 elements
   for T use (E80 => -16#80#, ..., E00 => 16#00#, ..., E7F => 16#7F#); -- -128
to +127
   for T'Size use 8;
   procedure P (X : T);
   pragma No_Inline (P);
   procedure P (X : T) is
   begin
  Ada.Integer_Text_IO.Put (T'Pos (X));
  Ada.Integer_Text_IO.Put (T'Enum_Rep (X)); -- GNAT BUG DETECTED
  Ada.Text_IO.New_Line;
   end P;
begin
   P (T'First);
   P (T'Last);
end test_enumrep2;

 gcc-10.2.0 

% /opt/ytomino/gcc-10.2.0/bin/gnatmake --version
GNATMAKE 10.2.0
Copyright (C) 1995-2020, Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

% /opt/ytomino/gcc-10.2.0/bin/gnatmake test_enumrep2.adb
gcc -c test_enumrep2.adb
gnatbind -x test_enumrep2.ali
gnatlink test_enumrep2.ali

% ./test_enumrep2 
  0   -128
255127

It's fine.

 gcc-11.1.0 

% /opt/ytomino/gcc-11.1.0/bin/gnatmake --version
GNATMAKE 11.1.0
Copyright (C) 1995-2021, Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

% /opt/ytomino/gcc-11.1.0/bin/gnatmake test_enumrep2.adb
gcc -c test_enumrep2.adb
gnatbind -x test_enumrep2.ali
gnatlink test_enumrep2.ali
% ./test_enumrep2
  0128
255127

Note, T'Enum_Rep(T'First) returns the unsigned value in gcc-11.1 because bug
101094.

 gcc-11.2.0 

% /opt/ytomino/gcc-11.2.0/bin/gnatmake --version
GNATMAKE 11.2.0
Copyright (C) 1995-2021, Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

% /opt/ytomino/gcc-11.2.0/bin/gnatmake test_enumrep2
gcc -c test_enumrep2.adb
+===GNAT BUG DETECTED==+
| 11.2.0 (x86_64-linux-gnu) GCC error: |
| in build_binary_op, at ada/gcc-interface/utils2.c:1164   |
| Error detected at test_enumrep2.adb:107:44   |
| Please submit a bug report; see https://gcc.gnu.org/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.   |
+==+

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).

test_enumrep2.adb

compilation abandoned
gnatmake: "test_enumrep2.adb" compilation error

[Bug ada/101094] New: [11 regression] 'Enum_Rep returns a unsigned value for the negative representation in gcc-11

2021-06-16 Thread demoonlit at panathenaia dot halfmoon.jp via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101094

Bug ID: 101094
   Summary: [11 regression] 'Enum_Rep returns a unsigned value for
the negative representation in gcc-11
   Product: gcc
   Version: 11.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: demoonlit at panathenaia dot halfmoon.jp
  Target Milestone: ---

'Enum_Rep returns a unsigned value for the run-time value having the negative
representation in gcc-11.
It also returns just a representation value for the compile-time value.

In gcc-10 or older, it always returns just a representation value.
Is this intentional changed or not?

Test code
-

with Ada.Text_IO;
with Ada.Integer_Text_IO;
procedure main is
   type T is (Nega, Zero, Posi);
   for T use (Nega => -1, Zero => 0, Posi => 1);
begin
   -- literal
   Ada.Text_IO.Put ("Lite:");
   Ada.Integer_Text_IO.Put (T'Enum_Rep (Nega)); -- "-1"
   Ada.Text_IO.New_Line;
   -- compile-time constant
   declare
  Cons : constant T := Nega;
   begin
  Ada.Text_IO.Put ("Cons:");
  Ada.Integer_Text_IO.Put (T'Enum_Rep (Cons)); -- "-1"
  Ada.Text_IO.New_Line;
   end;
   -- variable
   declare
  Vari : T := T'Value ("Nega");
   begin
  Ada.Text_IO.Put ("Vari:");
  Ada.Integer_Text_IO.Put (T'Enum_Rep (Vari)); -- "255"
  Ada.Text_IO.New_Line;
   end;
   -- parameter
   declare
  procedure Sub1 (Para : T) is
  begin
 Ada.Text_IO.Put ("Para:");
 Ada.Integer_Text_IO.Put (T'Enum_Rep (Para)); -- "255"
 Ada.Text_IO.New_Line;
  end Sub1;
   begin
  Sub1 (Nega);
   end;
end main;

With gcc-10
---

$ gnatmake --version
GNATMAKE 10.2.0
Copyright (C) 1995-2020, Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

$ gnatmake main
gcc -c main.adb
gnatbind -x main.ali
gnatlink main.ali

$ ./main
Lite: -1
Cons: -1
Vari: -1
Para: -1

With gcc-11
---

$ gnatmake --version
GNATMAKE 11.1.0
Copyright (C) 1995-2021, Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

$ gnatmake main
gcc -c main.adb
gnatbind -x main.ali
gnatlink main.ali

% ./main
Lite: -1
Cons: -1
Vari:255
Para:255

Thanks.

[Bug ada/70867] [9/10/11/12 regression] access discriminant in return aggregate wrongly detected as dangling

2021-06-10 Thread demoonlit at panathenaia dot halfmoon.jp via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70867

--- Comment #13 from yuta tomino  ---
Sorry, perhaps my example is illegal in Ada 2012.
"aliased" is required to return a reference of a part of the parameter.

Randy explained the change in
https://groups.google.com/g/comp.lang.ada/c/7dw7Oqi8lIk/m/5NUBhFN8DQAJ .
(I wonder if it was legal before Ada 2005?? Because aliased parameter is added
in Ada 2012 and the relevant text has been changed by AI05-0234-1.)

I think Nicolas's example is always legal.

Thanks.

[Bug ada/96799] New: C and Ada frontends have a different interpretation of double constants

2020-08-26 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96799

Bug ID: 96799
   Summary: C and Ada frontends have a different interpretation of
double constants
   Product: gcc
   Version: 10.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: demoonlit at panathenaia dot halfmoon.jp
  Target Milestone: ---

Hello.
Each of the C and Ada frontends has a different interpretation of the some kind
of double constants.

Reproducing:
Write the same small double constants for each language.

double1.c

const double d_min = 0x0.3eP-1072;


double2.ads

package double2 is
   d_min : constant Long_Float := 16#0.3e#e-268;
end double2;


(Note: These constants are the hexadecimal of __DBL_DENORM_MIN__ and wanted to
be rounded to the minimal value of double. The precise value is 0x0.4P-1072,
but __DBL_DENORM_MIN__ is a written as decimal, so these constants are got from
it by the conversion. This value is unimportant because perhaps this bug can be
reproduced with other values.)

Compile them.

$ gcc -W -Wall -S double1.c
$ gcc -W -Wall -S double2.ads
double2.ads:2:35: warning: floating-point value underflows to 0.0

Ada frontend reports the underflow. C frontend does not.
And compare double1.s and double2.s.

double1.s

.text
.globl _d_min
.const
.align 3
_d_min:
.long   1   # <- It has been rounded.
.long   0
.ident  "GCC: (GNU) 10.1.0"
.subsections_via_symbols


double2.s

.text
.globl _double2_E
.data
.align 1
_double2_E:
.space 2
.globl _double2__d_min
.const
.align 3
_double2__d_min:
.space 8# <- It has been truncated.
.ident  "GCC: (GNU) 10.1.0"
.subsections_via_symbols


I first noticed it in the FreeBSD 32bit. FreeBSD 32bit has the lesser precision
of long double than other environments. However, then I tried it in FreeBSD
64bit, Linux, and MacOSX and it is reproducible too.

[Bug ada/65696] ASAN reports global-buffer-overrun for local tagged types

2020-05-08 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65696

--- Comment #4 from yuta tomino  ---
I'm trying the released gcc-10.1, and confirmed that this is fixed.
Thank you.

[Bug ada/81956] [7/8/9 regression] calling a null procedure is not skipped

2019-02-25 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81956

--- Comment #3 from yuta tomino  ---
I'm trying gcc-8.3. This is probably fixed in 8.x.
Thanks.

[Bug ada/83002] New: Missing finalization of generic package body

2017-11-15 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83002

Bug ID: 83002
   Summary: Missing finalization of generic package body
   Product: gcc
   Version: 7.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: demoonlit at panathenaia dot halfmoon.jp
  Target Milestone: ---

Created attachment 42613
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42613=edit
bug triggering source code

Hello.

The finalizer of package body (postfixed "__finalize_body") for controlled
object is not generated when it is generic package (and its spec does not need
finalizer ?).

See the attached file and run. I've expected for getting "OK" outputted by the
finalizer, but did not. And it works correctly if the controlled object
declaration is moved to its spec.

This bug also appeared with GNAT-GPL 2017.


with x;
generic
package y is
   pragma elaborate_body;
end y;

package body y is
   object : x.t; -- this controlled object would not be finalized
end y;

[Bug ada/82746] New: strange error on BIP function returning private type with Disable_Controlled

2017-10-27 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82746

Bug ID: 82746
   Summary: strange error on BIP function returning private type
with Disable_Controlled
   Product: gcc
   Version: 7.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: demoonlit at panathenaia dot halfmoon.jp
  Target Milestone: ---

Created attachment 42488
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42488=edit
bug triggering source code

The compiler outputs strange error message ("" is undefined) on a
build-in-place function returning a type derived from a private type with
Disable_Controlled => True.

Compile the attached file:

% gcc -c pkg.adb
pkg.adb:17:07: "" is undefined


   function BIP_2 return T is
   begin
  return Result : T do -- pkg.adb:17:07: "" is undefined
 null;
  end return;
   end BIP_2;


[Bug ada/81961] [7 regression] an imported unsized C array in the auto-translated binding raises Storage_Error

2017-08-24 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81961

--- Comment #1 from yuta tomino  ---
Note, -gnatp or pragma Suppress can not suppress this exception.

[Bug ada/81961] New: [7 regression] an imported unsized C array in the auto-translated binding raises Storage_Error

2017-08-24 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81961

Bug ID: 81961
   Summary: [7 regression] an imported unsized C array in the
auto-translated binding raises Storage_Error
   Product: gcc
   Version: 7.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: demoonlit at panathenaia dot halfmoon.jp
  Target Milestone: ---

For example, translate a C header like following x.h with -fdump-ada-spec.

 x.h 
extern int unsized[];
=

$ gcc -c -fdump-ada-spec x.h

$ cat x_h.ads
pragma Ada_2005;
pragma Style_Checks (Off);

with Interfaces.C; use Interfaces.C;

package x_h is

   unsized : aliased array (size_t) of aliased int;  -- x.h:1
   pragma Import (C, unsized, "unsized");

end x_h;

And prepare a main routine, compile and execute it.

 main.adb 
with x_h;
procedure main is
begin
   null;
end main;
==

$ gnatmake main
gcc -c main.adb
gnatbind -x main.ali
gnatlink main.ali

$ ./main

raised STORAGE_ERROR : x_h.ads:8 object too large

This exception has been not appeared with gcc-6.

[Bug ada/81956] New: [7 regression] calling a null procedure is not skipped

2017-08-23 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81956

Bug ID: 81956
   Summary: [7 regression] calling a null procedure is not skipped
   Product: gcc
   Version: 7.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: demoonlit at panathenaia dot halfmoon.jp
  Target Milestone: ---

Hello. Has the behavior of null procedures been changed from gcc-7?

package p is
   procedure Null_Proc is null;
end p;

with p;
procedure main is
begin
   p.Null_Proc;
end main;

With gcc-7.2, the calling Null_Proc is generated into the object code.

$ gcc -c -O1 main.adb
$ nm main.o
0010 s EH_frame1
 S __ada_main
 U _p__null_proc

With gcc-6.2, this calling Null_Proc has been skipped. I think this behavior is
desirable.

$ gcc -c -O1 main.adb
$ nm main.o
0008 s EH_frame1
 S __ada_main

[Bug ada/65696] ASAN reports global-buffer-overrun for local tagged types

2017-05-14 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65696

--- Comment #2 from yuta tomino  ---
Here is a proposing fix.
I has tried this patch with gcc from 4.8 to 7, and it seems to work fine with
all versions.

diff --git a/gcc/ada/exp_atag.adb b/gcc/ada/exp_atag.adb
index 587432c..4313446 100644
--- a/gcc/ada/exp_atag.adb
+++ b/gcc/ada/exp_atag.adb
@@ -744,7 +744,8 @@ package body Exp_Atag is
function Build_Inherit_Predefined_Prims
  (Loc  : Source_Ptr;
   Old_Tag_Node : Node_Id;
-  New_Tag_Node : Node_Id) return Node_Id
+  New_Tag_Node : Node_Id;
+  Num_Predef_Prims : Int) return Node_Id
is
begin
   return
@@ -759,7 +760,7 @@ package body Exp_Atag is
 New_Tag_Node,
   Discrete_Range => Make_Range (Loc,
 Make_Integer_Literal (Loc, Uint_1),
-New_Occurrence_Of (RTE (RE_Max_Predef_Prims), Loc))),
+Make_Integer_Literal (Loc, Num_Predef_Prims))),

   Expression =>
 Make_Slice (Loc,
@@ -772,7 +773,7 @@ package body Exp_Atag is
   Discrete_Range =>
 Make_Range (Loc,
   Make_Integer_Literal (Loc, 1),
-  New_Occurrence_Of (RTE (RE_Max_Predef_Prims), Loc;
+  Make_Integer_Literal (Loc, Num_Predef_Prims;
end Build_Inherit_Predefined_Prims;

-
diff --git a/gcc/ada/exp_atag.ads b/gcc/ada/exp_atag.ads
index d53466f..eb4be55 100644
--- a/gcc/ada/exp_atag.ads
+++ b/gcc/ada/exp_atag.ads
@@ -111,7 +111,8 @@ package Exp_Atag is
function Build_Inherit_Predefined_Prims
  (Loc  : Source_Ptr;
   Old_Tag_Node : Node_Id;
-  New_Tag_Node : Node_Id) return Node_Id;
+  New_Tag_Node : Node_Id;
+  Num_Predef_Prims : Int) return Node_Id;
--  Build code that inherits the predefined primitives of the parent.
--
--  Generates: Predefined_DT (New_T).D (All_Predefined_Prims) :=
diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb
index 2b63377..ef7440f 100644
--- a/gcc/ada/exp_disp.adb
+++ b/gcc/ada/exp_disp.adb
@@ -4524,6 +4524,7 @@ package body Exp_Disp is
   Iface_Table_Node   : Node_Id;
   Name_ITable: Name_Id;
   Nb_Predef_Prims: Nat := 0;
+  Cp_Predef_Prims: Nat := 0;
   Nb_Prim: Nat := 0;
   New_Node   : Node_Id;
   Num_Ifaces : Nat := 0;
@@ -5690,10 +5691,6 @@ package body Exp_Disp is
 Pos : Nat;

  begin
-if not Building_Static_DT (Typ) then
-   Nb_Predef_Prims := Max_Predef_Prims;
-
-else
Prim_Elmt := First_Elmt (Primitive_Operations (Typ));
while Present (Prim_Elmt) loop
   Prim := Node (Prim_Elmt);
@@ -5703,13 +5700,18 @@ package body Exp_Disp is
   then
  Pos := UI_To_Int (DT_Position (Prim));

- if Pos > Nb_Predef_Prims then
-Nb_Predef_Prims := Pos;
+ if Pos > Cp_Predef_Prims then
+Cp_Predef_Prims := Pos;
  end if;
   end if;

   Next_Elmt (Prim_Elmt);
end loop;
+
+if not Building_Static_DT (Typ) then
+   Nb_Predef_Prims := Max_Predef_Prims;
+else
+   Nb_Predef_Prims := Cp_Predef_Prims;
 end if;

 declare
@@ -6054,7 +6056,8 @@ package body Exp_Disp is
   (Node
 (Next_Elmt
   (First_Elmt
-(Access_Disp_Table (Typ, Loc)));
+(Access_Disp_Table (Typ, Loc),
+  Num_Predef_Prims => Cp_Predef_Prims));

   if Nb_Prims /= 0 then
  Append_To (Elab_Code,
@@ -6143,7 +6146,8 @@ package body Exp_Disp is
   Unchecked_Convert_To (RTE (RE_Tag),
 New_Occurrence_Of
   (Node (Next_Elmt (Sec_DT_Typ)),
-   Loc;
+   Loc)),
+Num_Predef_Prims => Cp_Predef_Prims));

 if Num_Prims /= 0 then
Append_To (Elab_Code,
@@ -6189,7 +6193,8 @@ package body Exp_Disp is
   Unchecked_Convert_To (RTE (RE_Tag),
 New_Occurrence_Of
   (Node (Next_Elmt (Sec_DT_Typ)),
-   Loc;
+   Loc)),
+Num_Predef_Prims => Cp_Predef_Prims));

 

[Bug ada/70900] New: a library-level class-wide subprogram is not generated into .o/.s

2016-05-02 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70900

Bug ID: 70900
   Summary: a library-level class-wide subprogram is not generated
into .o/.s
   Product: gcc
   Version: 6.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: demoonlit at panathenaia dot halfmoon.jp
  Target Milestone: ---

gcc-6.1.0 does not generate machine-code for some kind of library-level
class-wide subprograms into .o/.s.

Minor difference of nest-level, profile, or body of it affects possible to
reproduce. I have not found the detailed condition, but found one reproducible
small code, below:

package p is
   type t is tagged null record;
end p;

with p;
function p.liblevelcwsubp (obj : p.t'class) return p.t'class is
begin
   return obj;
end p.liblevelcwsubp;

% x86_64-apple-darwin10-gcc -c p-liblevelcwsubp.adb
% nm p-liblevelcwsubp.o
nm: no name list

% x86_64-pc-linux-gnu-gcc -c p-liblevelcwsubp.adb
% x86_64-pc-linux-gnu-nm p-liblevelcwsubp.o
(empty output)

% x86_64-apple-darwin10-gcc -S p-liblevelcwsubp.adb
% cat p-liblevelcwsubp.s
.subsections_via_symbols
(end of file)

% x86_64-pc-linux-gnu-gcc -S p-liblevelcwsubp.adb 
% cat p-liblevelcwsubp.s
.file   "p-liblevelcwsubp.adb"
.ident  "GCC: (GNU) 6.1.0"
.section.note.GNU-stack,"",@progbits
(end of file)

% x86_64-apple-darwin10-gcc --version
x86_64-apple-darwin10-gcc (GCC) 6.1.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

% x86_64-pc-linux-gnu-gcc --version
x86_64-pc-linux-gnu-gcc (GCC) 6.1.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

--

gcc-5 works:

% gcc -c p-liblevelcwsubp.adb
% nm p-liblevelcwsubp.o
0230 s EH_frame1
 U ___gnat_rcheck_CE_Access_Check
 U ___gnat_rcheck_PE_Accessibility_Check
 T __ada_p__liblevelcwsubp
 U _memcpy
 U _system__secondary_stack__ss_allocate

% gcc -S p-liblevelcwsubp.adb
% cat p-liblevelcwsubp.s
.const
LC0:
.ascii "p-liblevelcwsubp.adb"
.space 1
.text
.globl __ada_p__liblevelcwsubp
__ada_p__liblevelcwsubp:
LFB2:
pushq   %rbp
LCFI0:
movq%rsp, %rbp
(...more contents)

% gcc --version
gcc (GCC) 5.3.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug ada/70867] access discriminant in return aggregate detected as dangling if set from an implicit dereference in generic package

2016-04-29 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70867

yuta tomino  changed:

   What|Removed |Added

 CC||demoonlit at panathenaia dot 
halfm
   ||oon.jp

--- Comment #1 from yuta tomino  ---
Hello. I have encountered a similar case, too.

package p is
   type T (D : access constant Integer) is null record; 
   type R is limited record
  Component : aliased Integer;
   end record;
   function F (Object : R) return T is
 (D => Object.Component'Access);
end p;

p.ads:7:12: access discriminant in return aggregate would be a dangling
reference

Inserting "aliased" between "Object :" and "R" resolves it.
However, "Object : R" is already passed by reference without aliased, because
in RM 6.2(7/3), an explicitly limited record type is a by-reference type unless
aliased.
So, it does not make a dangling reference.

[Bug ada/70645] New: [4.9/5/6 Regression] -fguess-branch-probability breaks debug-information, only in Ada

2016-04-13 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70645

Bug ID: 70645
   Summary: [4.9/5/6 Regression] -fguess-branch-probability breaks
debug-information, only in Ada
   Product: gcc
   Version: 6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: demoonlit at panathenaia dot halfmoon.jp
  Target Milestone: ---

I can not debug some executable files generated by recent gcc Ada frontend,
with all optimization-levels including -fguess-branch-probability.
(I'm troubled with -Og. I've understood that -Og is intended to debug.)

gcc-4.9, gcc-5, and gcc-6 have failed.
However, gcc-4.8 works well.

C/C++ and Fortran frontends work well on all versions.

Note, I tried gdb from 7.9 to 7.11 as debugger.

% cat hello.adb
with Ada.Text_IO;
procedure Hello is
begin
   Ada.Text_IO.Put_Line ("Hello.");
end Hello;

% gcc -v
gcc (GCC) 6.0.0 20160401 (experimental)
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

% gnatmake -g -Og hello
gcc -c -g -Og hello.adb
gnatbind -x hello.ali
gnatlink hello.ali -g -Og

% gdb hello 
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin10.8.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from hello...Reading symbols from
hello.dSYM/Contents/Resources/DWARF/hello...done.
done.
(gdb) start
Temporary breakpoint 1 at 0x114f1
Starting program: hello 

Temporary breakpoint 1, 0x000114f1 in hello ()
(gdb) s
Single stepping until exit from function _ada_hello,
which has no line number information. # <<<< Please look here 
Hello.
main (argc=, argv=, envp=)
at b~hello.adb:197
197   adafinal;
(gdb) quit
A debugging session is active.

Inferior 1 [process 45663] will be killed.

Quit anyway? (y or n) y

% gnatmake -f -g -Og -fno-guess-branch-probability hello
gcc -c -g -Og -fno-guess-branch-probability hello.adb
gnatbind -x hello.ali
gnatlink hello.ali -g -Og -fno-guess-branch-probability

% gdb hello 
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin10.8.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from hello...Reading symbols from
hello.dSYM/Contents/Resources/DWARF/hello...done.
done.
(gdb) start
Temporary breakpoint 1 at 0x1154e: file hello.adb, line 2.
Starting program: hello 

Temporary breakpoint 1, _ada_hello () at hello.adb:2
2   procedure Hello is
(gdb) s
4  Ada.Text_IO.Put_Line ("Hello."); # <<<< It works fine.
(gdb) s
ada__text_io__put_line__2 (item=...) at a-textio.adb:1424
1424   procedure Put_Line (Item : String) is
(gdb) quit
A debugging session is active.

Inferior 1 [process 45704] will be killed.

Quit anyway? (y or n) y


#  Example of gcc-4.8 from here: 


% gcc --version
gcc (GCC) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

% gnatmake -f -g -Og hello
gcc -c -g -Og hello.adb
gnatbind -x hello.ali
gnatlink hello.ali -g -Og

% gdb hello   
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free so

[Bug ada/69219] [5/6 regression] failed to compile nested subprograms with Inline_Always and Intrinsic

2016-01-12 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69219

--- Comment #5 from yuta tomino  ---
> "built-in" is because you use Intrinsic!  In any case, the rule of thumb is to
> never use pragma Inline_Always with anything except for very small 
> subprograms.

Well...
I believe above "IA" is a sufficiently small subprogram because it's one line!

...Instead of such a viewpoint, I think there are two sides of this problem.

1. The compiler rejects the code that seems syntactically legal, and this
behavior is depending on the place where the subprogram is instantiated.
There is no reason why it is accepted in the library-level and rejected in the
nested scope, especially when the pragmas are written in the generic package
practically.

2. The error message is confused. "" is one too.
I wish that "Intrinsic" is reported if Intrinsic is the cause.
And the other lines are also unclear.

> : In function 'nestedinlinealways.ia':
> nestedinlinealways.adb:3:14: error: subprogram 'nestedinlinealways.ni'
> not marked Inline_Always
> nestedinlinealways.adb:11:4: error: parent subprogram cannot be inlined

At first, I got them wrong that the cause is at "NI".
Next, it took time for me to understand which the "parent" is indicating.

These message should be improved like your explanation, even if this pattern
should be an error.

[Bug ada/69219] [5/6 regression] failed to compile nested subprograms with Inline_Always and Intrinsic

2016-01-12 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69219

--- Comment #8 from yuta tomino  ---
I'm glad that you are understanding that.

> pragma Inline_Always is not defined by the Ada language so you cannot
> invoke legality rules when you use it.
> It will issue an error when it cannot inline something and, yes, this
> depends on the context.

Sorry, I mixed and expected pragma Inline_Always as similar to pragma Inline.
I will pay attention to use of Inline_Always.

Thanks.

[Bug ada/69219] [5/6 regression] failed to compile nested subprograms with Inline_Always and Intrinsic

2016-01-11 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69219

--- Comment #2 from yuta tomino  ---
> Yes, remove the convention Intrinsic, it doesn't make any sense here or add 
> pragma Inline_Always on the nested subprogram as indicated.

I agree with your sense. The local subprograms would be optimized well without
the pragmas.
Of course, I did not write the code directly like described above.
Practically, I found this bug from some instantiations of the generic packages.

The real problem is that we can not use the pattern of Inline_Always and
Intrinsic, in writing any generic package, to reduce the code size for
instantiating it in the library-level, because of also allowing use of it in
the nested scope.

[Bug ada/69219] [5/6 regression] failed to compile nested subprograms with Inline_Always and Intrinsic

2016-01-11 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69219

yuta tomino  changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |---

--- Comment #3 from yuta tomino  ---
In addition, even if it should be an error, I think that the proper error
message should be reported instead of the  error.

[Bug ada/69219] New: [5/6 regression] failed to compile nested subprograms with Inline_Always and Intrinsic

2016-01-10 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69219

Bug ID: 69219
   Summary: [5/6 regression] failed to compile nested subprograms
with Inline_Always and Intrinsic
   Product: gcc
   Version: 6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: demoonlit at panathenaia dot halfmoon.jp
  Target Milestone: ---

Created attachment 37297
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37297=edit
minimal bug triggering source code

gcc-5 and later have generated no machine-code for subprograms having the
combination of Inline_Always and Intrinsic.
However, this pattern causes  error for nested subprograms.

procedure nestedinlinealways is -- outer subprogram

   procedure NI;
   pragma No_Inline (NI);

   procedure IA;
   pragma Convention (Intrinsic, IA);
   pragma Inline_Always (IA);
-- pragma Inline (IA); -- it works fine.

   procedure IA is
   begin
  NI; -- calling other subprogram here is one of the triggers.
   end IA;

   procedure NI is null;

begin
   IA;
end nestedinlinealways;

Please try to compile above code (the attached file):

% gcc -c nestedinlinealways.adb
: In function 'nestedinlinealways.ia':
nestedinlinealways.adb:3:14: error: subprogram 'nestedinlinealways.ni' not
marked Inline_Always
nestedinlinealways.adb:11:4: error: parent subprogram cannot be inlined

It will become to be compiled if I replace pragma Inline_Always to normal
Inline or remove pragma Convention.

[Bug ada/48002] internal error on calling inherited, overloaded and abstract subprograms with string literal

2015-09-01 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48002

yuta tomino  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #6 from yuta tomino  ---
I'm unsure about the rule of this Bugzilla, but allow me to close because this
bug has already been fixed.


[Bug ada/48039] Legal program rejected, a formal function is not visible in generic

2015-09-01 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48039

yuta tomino  changed:

   What|Removed |Added

Version|4.5.2   |6.0
  Known to fail||4.5.2

--- Comment #2 from yuta tomino  ---
It has appeared on 6.0.0-20150823.


[Bug ada/48013] generic instantiation breaks the restriction of No_Elaboration_Code

2015-09-01 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48013

yuta tomino  changed:

   What|Removed |Added

Version|4.5.2   |6.0
  Known to fail||4.5.2

--- Comment #2 from yuta tomino  ---
It has appeared on 6.0.0-20150823.


[Bug ada/48002] internal error on calling inherited, overloaded and abstract subprograms with string literal

2015-07-18 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48002

--- Comment #5 from yuta tomino demoonlit at panathenaia dot halfmoon.jp ---
This bug seems already being fixed as François-Xavier wrote. (it could be
compiled with gcc-5.1)
Thanks.

[Bug ada/65696] New: ASAN reports global-buffer-overrun for local tagged types

2015-04-08 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65696

Bug ID: 65696
   Summary: ASAN reports global-buffer-overrun for local tagged
types
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: demoonlit at panathenaia dot halfmoon.jp

package pkg_a is
   type Root is tagged null record;
end pkg_a;

with pkg_a;
procedure main is
   type Derived is new pkg_a.Root with null record;
begin
   null;
end main;

% gnatmake main.adb -cargs -fsanitize=address -largs -lasan.1
gcc -c -fsanitize=address main.adb
gcc -c -fsanitize=address pkg_a.ads
gnatbind -x main.ali
gnatlink main.ali -lasan.1

% ./main 
=
==78928==ERROR: AddressSanitizer: unknown-crash on address 0x0001000174c8 at pc
0x1303d bp 0x7fff5fbfed10 sp 0x7fff5fbfed08
READ of size 120 at 0x0001000174c8 thread T0
#0 0x1303c (main+0x1303c)
#1 0x123d4 (main+0x123d4)
#2 0x119d7 (main+0x119d7)
#3 0x0 (main+0x0)

0x000100017510 is located 0 bytes to the right of global variable
'pkg_a__rootR38s___UNC' from 'pkg_a.ads' (0x1000174c0) of size 80
SUMMARY: AddressSanitizer: unknown-crash ??:0 ??
Shadow bytes around the buggy address:
  0x100020002e40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100020002e50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100020002e60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100020002e70: 00 00 00 00 00 00 00 00 00 f9 f9 f9 f9 f9 f9 f9
  0x100020002e80: 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
=0x100020002e90: 00 00 f9 f9 f9 f9 f9 f9 00[00]00 00 00 00 00 00
  0x100020002ea0: 00 00 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9
  0x100020002eb0: 00 00 00 00 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 00
  0x100020002ec0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100020002ed0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100020002ee0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:   00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:   fa
  Heap right redzone:  fb
  Freed heap region:   fd
  Stack left redzone:  f1
  Stack mid redzone:   f2
  Stack right redzone: f3
  Stack partial redzone:   f4
  Stack after return:  f5
  Stack use after scope:   f8
  Global redzone:  f9
  Global init order:   f6
  Poisoned by user:f7
  Contiguous container OOB:fc
  ASan internal:   fe
==78928==ABORTING

Perhaps, a cause is the implicit code for making a child type's dispatching
table.
The size of copying of a parent type's predefined primitives to a child's is
Max_Predef_Prims (15), but the real number of a parent type's predefined
primitives seems 9.


[Bug ada/47748] Legal program rejected, ARM 12.7(3/2): generic formal package with others = in the formal_package_actual_part

2015-04-07 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47748

--- Comment #1 from yuta tomino demoonlit at panathenaia dot halfmoon.jp ---
It seems fixed with gcc-4.7.2, 4.8.1, 4.9.2 and 5-20150405.


[Bug ada/65683] New: [5 regression] access types across limited with breaks restriction of No_Elaboration_Code

2015-04-07 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65683

Bug ID: 65683
   Summary: [5 regression] access types across limited with
breaks restriction of No_Elaboration_Code
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: demoonlit at panathenaia dot halfmoon.jp

package pkg_a is
   type T is null record; -- non-controlled type
end pkg_a;

pragma Restrictions (No_Elaboration_Code);
limited with pkg_a;
package pkg_b is
   type P is access all pkg_a.T;
   for P'Storage_Size use 0;
end pkg_b;

Compile it with gcc-4.9.2.

  % gcc -c pkg_b.ads
  (success with no messages)

Compile it with gcc-5-20150405.

  % gcc -c pkg_b.ads
  pkg_b.ads:5:09: violation of restriction no_elaboration_code at line 2

See pkg_b.ads.dg by -gnatD, the unnecessary master is generated.

pragma restrictions (no_elaboration_code);
limited with pkg_a;
with system.system__soft_links;
with system.system__tasking;

package pkg_b is
   pkg_b___master : constant system__tasking__master_id :=
 system__soft_links__current_master.all;
   pkg_b__pM : system__tasking__master_id renames pkg_b___master;
   type pkg_b__p is access all pkg_a.t;
   for pkg_b__p'storage_size use 0;
   freeze pkg_b__p []
end pkg_b;

[subtype T1s is String (1 .. 73);]
freeze_generic T1s
freeze_generic object_pointer

This master has not appeared until gcc-4.9.
And, if limited is removed, it disappears with gcc-5-20150405.


[Bug ada/62205] GNAT does not accept class types for Default_Iterator

2015-04-07 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62205

--- Comment #3 from yuta tomino demoonlit at panathenaia dot halfmoon.jp ---
It seems fixed with gcc-5-20150405.


[Bug ada/65524] New: gnatbind generates decrementing the unexisting elab-counter into finalize_library

2015-03-23 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65524

Bug ID: 65524
   Summary: gnatbind generates decrementing the unexisting
elab-counter into finalize_library
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: demoonlit at panathenaia dot halfmoon.jp

I found some cases that gnatbind generates decrementing the unexisting
elaboration counter of each package Exxx.

   E142 : Short_Integer; pragma Import (Ada, E142, system__exn_lli_E);
   ... some Exxx are declared ...

   procedure finalize_library is
   begin
  ...
  E132 := E132 - 1; -- * E132 is not declared in above *
  ...
   end finalize_library;

A cause is a package having _finalize_spec/_finalize_body without
_elabs/_elabb.
I still have not been able to make the minimal example, but have made a patch.

In bindgen.adb, Gen_Elab_Externals refers U.Set_Elab_Entity to generate Exxx.
However, Gen_Finalize_Library does not refer it.

--- a/gcc/ada/bindgen.adb
+++ b/gcc/ada/bindgen.adb
@@ -1434,7 +1434,9 @@ package body Bindgen is
 --  has a finalizer. In that case, this is where we decrement
 --  the elaboration entity.

-if U.Utype = Is_Body and then Uspec.Has_Finalizer then
+if U.Utype = Is_Body and then Uspec.Has_Finalizer
+   and then Uspec.Set_Elab_Entity
+then
if not Lib_Final_Built then
   Gen_Header;
   Lib_Final_Built := True;
@@ -1548,7 +1550,9 @@ package body Bindgen is

 WBI (  begin);

-if U.Utype /= Is_Spec then
+if U.Utype /= Is_Spec
+   and then Uspec.Set_Elab_Entity
+then
Set_String ( E);
Set_Unit_Number (Unum);
Set_String ( := E);


[Bug ada/65524] gnatbind generates decrementing the unexisting elab-counter into finalize_library

2015-03-23 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65524

--- Comment #2 from yuta tomino demoonlit at panathenaia dot halfmoon.jp ---
Created attachment 35115
  -- https://gcc.gnu.org/bugzilla/attachment.cgi?id=35115action=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.


[Bug ada/64548] Lost visibility of package System after raise

2015-02-16 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64548

--- Comment #5 from yuta tomino demoonlit at panathenaia dot halfmoon.jp ---
Hello, Simon.
I'm glad to look at this report.

I have a similar experience like this.
The trigger of mine was not private with but a nested package in the spec of
Ada.Exceptions.

I should think it's useless information, but I would write, just in case.


[Bug ada/62117] [4.9 regression] wrong code for passing small array argument'Address, in generic

2015-02-01 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62117

--- Comment #3 from yuta tomino demoonlit at panathenaia dot halfmoon.jp ---
I understood by trial and error that pragma Pure_Function is equivalent to
__attribute__((const)).
I'm sorry. The first case (in my first description) is not compiler's bug but
my mistake. The parameters Left and Right were erased by optimization because
compiler assumed that Pure_Function does not dereference, in my current
understanding.

Also, the case2 (in comment 2) is not reproduced by gcc-5.
However, the reason is that System.Fat_Flt.Unaligned_Valid is removed on gcc-5.


...By the way, I found an another point that I'm concerned.

In the document of pragma Pure_Function, a function having Address parameter is
not considered as Pure_Function.

https://gcc.gnu.org/onlinedocs/gnat_rm/Pragma-Pure_005fFunction.html

 One exception is any function that has at least one formal of type 
 System.Address or a type derived from it. Such functions are not considered 
 pure by default,

But,

with System;
package case3_p is
   pragma Pure;
   function F (X : System.Address) return System.Address;
end case3_p;

package body case3_p is
   function F (X : System.Address) return System.Address is
   begin
  return X;
   end F;
end case3_p;

with case3_p;
with System.Storage_Elements; use System.Storage_Elements;
with GNAT.IO;
procedure case3_m is
begin
   GNAT.IO.Put (Integer (To_Integer (case3_p.F (System'To_Address (10);
   GNAT.IO.Put (Integer (To_Integer (case3_p.F (System'To_Address (10);
   GNAT.IO.Put (Integer (To_Integer (case3_p.F (System'To_Address (10);
end case3_m;

Compile this case3_m.adb with optimization.

% gcc -S -O -gnatp case3_m.adb

.text
.globl __ada_case3_m
__ada_case3_m:
LFB1:
pushq%rbx
LCFI0:
movl$10, %edi
call_case3_p__f
movq%rax, %rbx
movl%eax, %edi
call_gnat__io__put__2
movl%ebx, %edi
call_gnat__io__put__2
movl%ebx, %edi
call_gnat__io__put__2
popq%rbx
LCFI1:
ret

_case3_p__f is called once on the machine code against that case3_p.F is called
three times from case3_m.
Perhaps, case3_p.F is treated as Pure_Function.

Which of those is correct, the document or the behaviour of compiler?


[Bug ada/64869] New: use all type clause is ineffective

2015-01-29 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64869

Bug ID: 64869
   Summary: use all type clause is ineffective
   Product: gcc
   Version: 5.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: demoonlit at panathenaia dot halfmoon.jp

use all type clauses for nested packages from an outer subprogram are
ineffective.

procedure case1 is
   package P is
  type T is (X, Y, Z);
  procedure Proc (Obj : T) is null;
   end P;
-- procedure Nested is
--use all type P.T; -- effective in nested subprogram
--Obj : P.T := X;
-- begin
--Proc (Obj); -- visible
-- end Nested;
   use all type P.T;
   Obj : P.T := X; -- invisible
begin
   Proc (Obj); -- invisible
end case1;

% gcc -c case1.adb 
case1.adb:2:09: missing body for P
case1.adb:13:22: X is not visible
case1.adb:13:22: non-visible declaration at line 3
case1.adb:15:09: Proc is not visible
case1.adb:15:09: non-visible declaration at line 4

with Ada.Containers.Vectors;
procedure case2 is
   package Vectors is new Ada.Containers.Vectors (Positive, Character);
-- procedure Nested is
--use all type Vectors.Vector; -- effective in nested subprogram
--X : Vectors.Vector := To_Vector (0); -- visible
-- begin
--Append (X, 'A'); -- visible
-- end Nested;
   use all type Vectors.Vector;
   X : Vectors.Vector := To_Vector (0); -- visible
begin
   Append (X, 'A'); -- invisible
end case2;

% gcc -c case2.adb
case2.adb:13:09: Append is not visible
case2.adb:13:09: non-visible declaration at a-convec.ads:243, instance at line
3
case2.adb:13:09: non-visible declaration at a-convec.ads:239, instance at line
3

Note, use all type clauses from nested sibling subprograms (commented out
subprograms Nested in above examples) are effective, and, strangely, above
examples will become to be compiled with the subprograms Nested (??)


[Bug ada/64349] [5 Regression] Bootstrapping Ada fails on darwin(9|10).

2015-01-26 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64349

yuta tomino demoonlit at panathenaia dot halfmoon.jp changed:

   What|Removed |Added

 CC||demoonlit at panathenaia dot 
halfm
   ||oon.jp

--- Comment #10 from yuta tomino demoonlit at panathenaia dot halfmoon.jp ---
Please move #ifdef in the correct order.

--- a/gcc/ada/env.c
+++ b/gcc/ada/env.c
@@ -44,12 +44,6 @@
 #include stdlib.h
 #endif

-#if defined (__APPLE__)  !defined (__arm__)
-/* On Darwin, _NSGetEnviron must be used for shared libraries; but it is not
-   available on iOS.  */
-#include crt_externs.h
-#endif
-
 #if defined (__vxworks)
   #if defined (__RTP__)
 /* On VxWorks 6 Real-Time process mode, environ is defined in unistd.h. 
*/
@@ -78,6 +72,12 @@
 #include system.h
 #endif /* IN_RTS */

+#if defined (__APPLE__)  !defined (__arm__)
+/* On Darwin, _NSGetEnviron must be used for shared libraries; but it is not
+   available on iOS.  */
+#include crt_externs.h
+#endif
+
 #ifdef __cplusplus
 extern C {
 #endif
@@ -215,11 +215,11 @@ __gnat_environ (void)
 #elif defined (sun)
   extern char **_environ;
   return _environ;
+#elif defined (__APPLE__)  !defined (__arm__)
+  return *_NSGetEnviron ();
 #elif ! (defined (__vxworks))
   extern char **environ;
   return environ;
-#elif defined (__APPLE__)  !defined (__arm__)
-  return *_NSGetEnviron ();
 #else
   return environ;
 #endif


[Bug ada/63276] New: implicit access checking is inserted for not null access type against pragma Suppress (Access_Check)

2014-09-16 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63276

Bug ID: 63276
   Summary: implicit access checking is inserted for not null
access type against pragma Suppress (Access_Check)
   Product: gcc
   Version: 4.9.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: demoonlit at panathenaia dot halfmoon.jp

The compiler inserts implicit access checking for not null access types
against pragma Suppress (Access_Check).

example:

 global.ads 
package global is
   type ptr is access all Integer;
   pragma Suppress (Access_Check, ptr);
   var : aliased Integer := 0;
   ref : not null ptr := var'Access; -- this not null is the trigger
   pragma Suppress (Access_Check, ref);
end global;

 main.ads 
with global;
procedure main is
begin
   global.ref.all := 1;
end main;

Compile main.ads and use nm to look for inserted implicit checking

$ gcc -c -gnatB main.adb
$ nm main.o
0048 s EH_frame1
 U ___gnat_rcheck_CE_Access_Check # unexpected access checking
is inserted!
 T __ada_main
 U _global__ref

For confirmation that not null is the trigger, delete not null from
global.ads

   ref : ptr := var'Access;

And recompile main.adb, use nm

$ gcc -c -gnatB main.adb
$ nm build/main.o
0018 s EH_frame1
 T __ada_main
 U _global__ref

The access checking is removed as intended, this time.


[Bug ada/62117] [4.9 regression] wrong code for passing small array argument'Address, in generic

2014-08-26 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62117

yuta tomino demoonlit at panathenaia dot halfmoon.jp changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |---

--- Comment #2 from yuta tomino demoonlit at panathenaia dot halfmoon.jp ---
Thank you for looking, Eric.

Surely, as you say, memcmp is unsuitable for presenting an example.
It's my mistake. But I had not found other case at the time.

I found another case since then. Pure is not a trigger in this case.
Please look this, too.

In the new case, it uses Float'Valid attribute calling
System.Fat_Flt.Unaligned_Valid implicitly.
Unaligned_Valid takes an Address argument. But it's not marked as pure.
And, it's a detail of compiler implementation. I think this behavior should not
affect application code.

It needs the type U for calling Unaligned_Valid.
If this type is removed (and some other method like Unchecked_Conversion is
used), System.Fat_Flt.Valid may be called instead of Unaligned_Valid.
System.Fat_Flt.Valid works correctly.

I apologize for taking your time.

-- case2.ads
package case2 is
   --  not pure package

   function Packed_Unaligned_Valid (Item : Long_Long_Integer) return Boolean;
   --  not pure function

end case2;

-- case2.adb
with system.storage_elements;
package body case2 is
   use type System.Storage_Elements.Storage_Offset;

   --  A Float value is packed into the argument Item, at unaligned position.
   type U is record
  C : Character;
  F : Float;
   end record;
   pragma Pack (U);

   function Packed_Unaligned_Valid (Item : Long_Long_Integer) return Boolean is
  X : U;
  for X'Address use Item'Address;
   begin
  return X.F'Valid; -- implicit calling System.Fat_Flt.Unaligned_Valid
   end Packed_Unaligned_Valid;

end case2;

 gcc-4.9 
_case2__packed_unaligned_valid:
LFB3:
subq$24, %rsp
LCFI0:
leaq9(%rsp), %rdi
call_system__fat_flt__attr_float__unaligned_valid
addq$24, %rsp
LCFI1:
ret

=== gcc-4.8 
_case2__packed_unaligned_valid:
LFB3:
subq$24, %rsp
LCFI0:
movq%rdi, 8(%rsp) # this operation is missing in gcc-4.9
leaq9(%rsp), %rdi
call_system__fat_flt__attr_float__unaligned_valid
addq$24, %rsp
LCFI1:
ret


[Bug ada/62230] New: Legal program rejected, RM 4.3.2(3, 5/3), ancestor_part can not be expression against error message by compiler itself

2014-08-22 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62230

Bug ID: 62230
   Summary: Legal program rejected, RM 4.3.2(3, 5/3),
ancestor_part can not be expression against error
message by compiler itself
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: demoonlit at panathenaia dot halfmoon.jp

Created attachment 33380
  -- https://gcc.gnu.org/bugzilla/attachment.cgi?id=33380action=edit
minimal bug triggering source code

GNAT rejects any expressions implying aggregate for ancestor_part.

For example: (Please see the attachment file, also)
   type T1 is limited new Ada.Finalization.Limited_Controlled with null record;
   type T2 is new T1 with null record;
   X : T2 := (T1 with null record); -- OK
   Z : T2 := (T1'(Ada.Finalization.Limited_Controlled with null record) with
null record); -- ERROR

GNAT outputs:
main.adb:23:09: limited ancestor part must be aggregate or function call

It seems for me that aggregate expression is allowed into ancestor_part
according to the error message outputted by GNAT itself. But, it is not.

And, RM 4.3.2(3, 5/3) allows it explicitly.


[Bug ada/62117] New: [4.9 regression] wrong code for passing small array argument'Address, in generic

2014-08-13 Thread demoonlit at panathenaia dot halfmoon.jp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62117

Bug ID: 62117
   Summary: [4.9 regression] wrong code for passing small array
argument'Address, in generic
   Product: gcc
   Version: 4.9.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: demoonlit at panathenaia dot halfmoon.jp

Created attachment 33306
  -- https://gcc.gnu.org/bugzilla/attachment.cgi?id=33306action=edit
minimal bug triggering source code

When instantiating a generic function like below, with a small array type
placed in register, according to x86_64 System V calling convension,

   generic
  type Key_Type is limited private;
   function Compare (Left, Right : Key_Type) return Integer;

'Address attributes of arguments point wrong place.
The compiler probably has forgotten to store the arguments to memory.

For example, if the body calls memcmp,

   function Compare (Left, Right : Key_Type) return Integer is
   begin
  return memcmp (Left'Address, Right'Address, Key_Type'Size / 8);
   end Compare;

The generated code compiled with -S -Og:

 gcc-4.9 
_inst__compare:
LFB1:
subq$40, %rsp
LCFI0:
movq%rsp, %rsi  # Left and Right are passed by %rdi and %rsi
leaq16(%rsp), %rdi # but this generated code overwrites them
movl$4, %edx
call_memcmp
addq$40, %rsp
LCFI1:
ret

This bug has appeared from gcc-4.9. gcc-4.8 is ok.

=== gcc-4.8 
_inst__compare:
LFB1:
subq$40, %rsp
LCFI0:
movl%edi, 16(%rsp) # Left and Right are stored on the stack
movl%esi, (%rsp)
movq%rsp, %rsi
leaq16(%rsp), %rdi
movl$4, %edx
call_memcmp
addq$40, %rsp
LCFI1:
ret


[Bug ada/59234] New: Legal program rejected, a generic package having intricate formal package parameters could not be instantiated

2013-11-21 Thread demoonlit at panathenaia dot halfmoon.jp
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59234

Bug ID: 59234
   Summary: Legal program rejected, a generic package having
intricate formal package parameters could not be
instantiated
   Product: gcc
   Version: 4.8.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: demoonlit at panathenaia dot halfmoon.jp

Created attachment 31263
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=31263action=edit
minimal bug triggering source code

It could not compile a generic package having intricate formal package
parameters.

The generic package (X) having two formal package parameters, another generic
package (Y) and its child generic package (Y.C).
The 2nd generic package (Y) also having a formal package parameter that is 4th
generic package (Z).

In this case, The generic package X could not be instantiated.

(If Y.C or Z is removed, X would be able to be instantiated.)

An example is in the attached file:

$ gnatmake main.adb 
gcc -c main.adb
main.adb:8:30: actual parameter must be instance of nested
main.adb:8:30: instantiation abandoned
gnatmake: main.adb compilation error

This bug has also been discussed on comp.lang.ada. Some people suggested me to
report.
https://groups.google.com/d/msg/comp.lang.ada/3UyNvf6KXRE/sjJB1zcmg7kJ

Regards.


[Bug ada/55725] New: Anonymous access returned from library-level function is finalized too early, RM 3.10.2(10/2 or 10.3/3)

2012-12-17 Thread demoonlit at panathenaia dot halfmoon.jp


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



 Bug #: 55725

   Summary: Anonymous access returned from library-level function

is finalized too early, RM 3.10.2(10/2 or 10.3/3)

Classification: Unclassified

   Product: gcc

   Version: 4.7.2

Status: UNCONFIRMED

  Severity: normal

  Priority: P3

 Component: ada

AssignedTo: unassig...@gcc.gnu.org

ReportedBy: demoon...@panathenaia.halfmoon.jp





Created attachment 28989

  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=28989

minimal bug triggering source code



An allocated object via anonymous access type returned from a library-level

function like F may be finalized inside of the function.



with Something; 

function F return access T;



function F return access T is

begin

   return new T; -- It returns new allocated value

   -- The allocated object may be finalized here

end F;



If a function is declared in a package, it behaves right.



This bug has also been discussed on comp.lang.ada.


[Bug ada/48293] New: Legal program rejected, empty discriminant blocks object allocation with built-in-place

2011-03-26 Thread demoonlit at panathenaia dot halfmoon.jp
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48293

   Summary: Legal program rejected, empty discriminant blocks
object allocation with built-in-place
   Product: gcc
   Version: 4.6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: demoon...@panathenaia.halfmoon.jp


Created attachment 23774
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=23774
minimal bug triggering source code

Compiler rejects allocating limited-type with function call (built-in-place) if
the limited type has *empty* discriminant.
(simple workaround is available, adding *dummy* discriminant)

with Ada.Finalization;
procedure min is
   -- bug sample
   package P1 is
  type T () is limited private;
  function F return T;
   private
  type T is new Ada.Finalization.Limited_Controlled with null record;
   end P1;
   package body P1 is
  function F return T is
  begin
 return (Ada.Finalization.Limited_Controlled with null record);
  end F;
   end P1;
   X1 : P1.T := P1.T'(P1.F); -- OK
-- X2 : access P1.T := new P1.T; -- this code is illegal, it should be error.
   X3 : access P1.T := new P1.T'(P1.F); -- this code is legal, but error
   --  workaround
   package P2 is
  type T () is limited private;
  function F return T;
   private
  type T (Dummy : Integer) is new Ada.Finalization.Limited_Controlled with
null record;
  --  add dummy discriminants
   end P2;
   package body P2 is
  function F return T is
  begin
 return (Ada.Finalization.Limited_Controlled with Dummy = 0);
  end F;
   end P2;
   X4 : access P2.T := new P2.T'(P2.F); -- OK
begin
   null;
end min;


[Bug ada/48293] Legal program rejected, empty discriminant blocks object allocation with built-in-place

2011-03-26 Thread demoonlit at panathenaia dot halfmoon.jp
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48293

--- Comment #1 from yuta tomino demoonlit at panathenaia dot halfmoon.jp 
2011-03-26 07:31:35 UTC ---
I'm sorry about wrong attachments.
I deleted limited of P1.T by mistake, please add limited or look the code
in the report.


[Bug ada/48039] New: Legal program rejected, a formal function is not visible in generic

2011-03-09 Thread demoonlit at panathenaia dot halfmoon.jp
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48039

   Summary: Legal program rejected, a formal function is not
visible in generic
   Product: gcc
   Version: 4.5.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: demoon...@panathenaia.halfmoon.jp


Created attachment 23589
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=23589
minimal bug triggering source code

Name lookup is abnormal in complex generic code with gcc-4.5.1/4.5.2.

-- p.ads
package p is
end p;

-- p-gh.ads
generic
function p.gh return Integer;

-- p-gh.adb
function p.gh return Integer is
begin
   return 0;
end p.gh;

-- p-gu.ads
generic
package p.gu is
   generic
  with function h return Integer is ;
  -- with function fh return Integer is ; -- ok
   function gh return Integer;
end p.gu;

-- p-gu.adb
package body p.gu is
   function gh return Integer is
   begin
  return h; -- error !!
  -- return fh; -- ok
   end gh;
end p.gu;

-- p-h.ads
with p.gh;
function p.h is new gh;

-- p-u.ads
with p.gu;
package p.u is new gu;

-- p-r.ads
with p.u;
package p.r is
end p.r;

-- p-r-h.ads
with p.h;
function p.r.h is new u.gh (h);

% gnatmake p-r-h.ads 
gcc -c p-r-h.ads
p-r-h.ads:4:01: instantiation error at p-gu.adb:6
p-r-h.ads:4:01: h is not visible
p-r-h.ads:4:01: instantiation error at p-gu.adb:6
p-r-h.ads:4:01: non-visible declaration at line 4
p-r-h.ads:4:01: instantiation error at p-gu.adb:6
p-r-h.ads:4:01: non-visible declaration at p-h.ads:4
gnatmake: p-r-h.ads compilation error

This code will be compiled If we rename formal function h to another name (for
example, fh).


[Bug ada/48013] New: generic instantiation breaks the restriction of No_Elaboration_Code

2011-03-07 Thread demoonlit at panathenaia dot halfmoon.jp
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48013

   Summary: generic instantiation breaks the restriction of
No_Elaboration_Code
   Product: gcc
   Version: 4.5.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: demoon...@panathenaia.halfmoon.jp


Created attachment 23565
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=23565
minimal bug triggering source code

Unnecessary elaboration code is generated by generic instantiation
with gcc-4.5.1/4.5.2/4.6.0(experimental at 20110225).

1. instantiate any generic package/subprogram in the library-level package.
2. gnatbind an application including this package.

pragma Restrictions (No_Elaboration_Code) and pragma No_Run_Time are not
effective in this problem.
I expected that elaboration code will be removed or reported warning/error by
Restrictions (No_Elaboration_Code).

-- t_m.adb

pragma Restrictions (No_Elaboration_Code);
pragma No_Run_Time;
with t_i;
procedure t_m is
begin
   null;
end t_m;

-- t_g.ads

pragma Restrictions (No_Elaboration_Code);
pragma No_Run_Time;
generic
procedure t_g;
pragma Pure (t_g);

-- t_g.adb

pragma Restrictions (No_Elaboration_Code);
pragma No_Run_Time;
procedure t_g is
begin
   null;
end t_g;

-- t_i.adb

pragma Restrictions (No_Elaboration_Code);
pragma No_Run_Time;
with t_g;
package t_i is
   pragma Pure (t_i);
   procedure nested is new t_g; -- *1
end t_i;

% gnatmake -g t_m 
gcc -c -g t_m.adb 
gcc -c -g t_i.ads 
gcc -c -g t_g.adb 
gnatbind -x t_m.ali 
gnatlink t_m.ali -g 

Look adainit in b~t_m.adb.

   procedure adainit is 
  E2 : Boolean; pragma Import (Ada, E2, t_i_E); 
   begin 
  null; 
  t_i'elab_spec; -- it violates No_Elaboration_Code !
  E2 := True; 
   end adainit; 

% nm t_i.o 
0261 D _t_i_E 
0008 T _t_i___elabs
 T _t_i__nested 

(Remove generic instantiation (*1), and re-compile these, 
then, elaboration code disappeared from adainit in b~t_m.adb
and __elabs procedure disappeared from t_i.o too.)


[Bug ada/48002] New: internal error on calling inherited, overloaded and abstract subprograms with string literal

2011-03-06 Thread demoonlit at panathenaia dot halfmoon.jp
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48002

   Summary: internal error on calling inherited, overloaded and
abstract subprograms with string literal
   Product: gcc
   Version: 4.5.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: demoon...@panathenaia.halfmoon.jp


Created attachment 23560
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=23560
minimal bug triggering source code

gcc-4.5.1 and 4.5.2 crash with internal error.

1. declare a type (named A.T) and primitive subprogram (named A.F) having a
String parameter.
2. declare new type (named B.T) derived from A.T, this type has inherited
subprogram B.F from A.F.
3. re-declare B.F as abstract to hide.
4. overload B.F having a Wide_String parameter.
5. call Wide_String version of B.F with string literal.

minimal source:

procedure overload_str is
package A is
type T is new Integer;
procedure F (X : T; Y : String) is null;
end A;
package B is
type T is new A.T;
procedure F (X : T; Y : Wide_String) is null;
procedure F (X : T; Y : String) is abstract; -- hide inherited F
end B;
begin
B.F (B.T'(0), ABC); -- compiler may crash
B.F (B.T'(0), Wide_String'(ABC)); -- OK
end overload_str;

% gnatmake overload_str
gcc -c overload_str.adb
+===GNAT BUG DETECTED==+
| 4.5.2 (i686-apple-darwin9) Assert_Failure einfo.adb:1698 |
| Error detected at overload_str.adb:12:10 |
| 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 or gnatmake command that you entered.  |
| Also include sources listed below in gnatchop format |
| (concatenated together with no headers between files).   |
+==+

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).

overload_str.adb

compilation abandoned
gnatmake: overload_str.adb compilation error


[Bug ada/48012] New: The executable file hangs up by combination of controlled-type, generic, renames and Inline_Always

2011-03-06 Thread demoonlit at panathenaia dot halfmoon.jp
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48012

   Summary: The executable file hangs up by combination of
controlled-type, generic, renames and Inline_Always
   Product: gcc
   Version: 4.5.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: demoon...@panathenaia.halfmoon.jp


Created attachment 23564
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=23564
minimal bug triggering source code

My application hangs up conpilied with gcc-4.5.2.

1. declare a controlled-type (named T) as private.
2. declare a generic function (named G) return T.
3. instantiate G.
4. declare a function (named F) renames it, and write pramga Inline_Always.
5. call F, it may hang up!

Probably, an object of T is attached to a finalization list, twice.

-- iacm.adb

with iact;
with iacp;
procedure iacm is
   X : iact.T := iacp.F; -- hang up !!
begin
null;
end iacm;

-- iact.ads

with Ada.Finalization;
package iact is
   type T is private; -- hidden controll type
   generic function G return T;
private
   type T is new Ada.Finalization.Controlled with null record;
end iact;

-- iact.adb

package body iact is
   function G return T is
   begin
  return (Ada.Finalization.Controlled with null record);
   end G;
end iact;

-- iacp.ads

with iact;
package iacp is
   function F return  iact.T;
   pragma Inline_Always (F); -- this pragma causes hang up
private
   function G is new iact.G;
   function F return iact.T renames G;
end iacp;

% gnatmake iacm
gcc -c iacm.adb
gcc -c iacp.ads
gcc -c iact.adb
gnatbind -x iacm.ali
gnatlink iacm.ali

% ./iacm 
( hang up !! )