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