[Bug ada/115535] New: Image attribute on arrays incorrectly prints a signed representation under certain conditions

2024-06-18 Thread liam at liampwll dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115535

Bug ID: 115535
   Summary: Image attribute on arrays incorrectly prints a signed
representation under certain conditions
   Product: gcc
   Version: 13.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: liam at liampwll dot com
CC: dkm at gcc dot gnu.org
  Target Milestone: ---

When calling 'Image on arrays containing range 0 .. 2**32 - 1 the output does
not match the output of 'Image for each element and instead outputs the value
interpreted as a signed 32 bit number.

GCC version: x64 13.2.0 from Alire on Linux and trunk on godbolt.org

Example built with gcc -c -I/app/ -g -fdiagnostics-color=always -S
-fverbose-asm -masm=intel -gnat2022 -o /app/example.s -I-:

with Ada.Text_IO; use Ada.Text_IO;
with System;

procedure Example is
type Client_ID_Part is range 0 .. 2**32 - 1 with
  Size => 32;
   type Client_ID is array (1 .. 2) of Client_ID_Part;
A : Client_ID := (1479222903, 3163714999);
begin
   Put_Line (A'Image);
   Put_Line (A (1)'Image);
   Put_Line (A (2)'Image);
end Example;

Actual output:

[ 1479222903, -1131252297]
 1479222903
 3163714999

Expected output:

[ 1479222903, 3163714999]
 1479222903
 3163714999

[Bug ada/116832] Code after a select-then-abort in an abortable part executes when the outer select-then-abort completes

2024-09-26 Thread liam at liampwll dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116832

--- Comment #5 from Liam Powell  ---
See the following code (shortened for clarity). There's probably a way to do
this without them, but our workaround works here.

select
   Connection.Hold; --  Continues after update is done
then abort
   declare
  Occurrence : Ada.Exceptions.Exception_Occurrence;
   begin
  select
 Fatal_Exception_Occurrence_Holder.Get (Occurrence);
  then abort
 Update_Check.Block_Until_Check_For_Update;
 --  Prompt user if required
 Update_Check.Block_Until_Update_Allowed;
 --  Tell user update is running
  end select;
  Fatal_Exception_Occurrence_Holder.Get (Occurrence);
  --  Above line to compensate for GCC bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116832
  --  Display error
   end;
   Connection.Hold; --  Continues after update is done
end select;

[Bug ada/116832] New: Code after a select-then-abort in an abortable part executes when the outer select-then-abort completes

2024-09-24 Thread liam at liampwll dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116832

Bug ID: 116832
   Summary: Code after a select-then-abort in an abortable part
executes when the outer select-then-abort completes
   Product: gcc
   Version: 14.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: liam at liampwll dot com
CC: dkm at gcc dot gnu.org
  Target Milestone: ---

As shown by the code below, code after a select-then-abort in an abortable part
executes when the outer select-then-abort completes. This only occurs when B is
a protected object rather than a task. This is potentially related to bug
52280, which is still reproducible. This occurs on trunk, 14.2.1, and 8.2.
Other versions are untested.

with Ada.Text_IO; use Ada.Text_IO;

procedure Example is
   task A is
  entry A;
   end A;

   protected B is
  entry B;
   end B;

   task body A is
   begin
  delay 3.0;
  accept A;
   end A;

   protected body B is
  entry B when False is
  begin
 Ada.Text_IO.Put_Line ("This correctly never executes.");
  end B;
   end B;
begin
   select
  A.A;
   then abort
  select
 B.B;
  then abort
 B.B;
  end select;
  Ada.Text_IO.Put_Line ("This should be unreachable but it executes.");
   end select;
end Example;

[Bug ada/116832] Code after a select-then-abort in an abortable part executes when the outer select-then-abort completes

2024-09-24 Thread liam at liampwll dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116832

--- Comment #1 from Liam Powell  ---
s/bug 52280/bug 43485

[Bug ada/116832] Code after a select-then-abort in an abortable part executes when the outer select-then-abort completes

2024-09-24 Thread liam at liampwll dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116832

--- Comment #2 from Liam Powell  ---
Here is another example I have found. In this case just one accept triggers
both selects. All Puts here are executed.

with Ada.Text_IO; use Ada.Text_IO;
with System;

procedure Example is
   task A is
  entry A;
   end A;

   task body A is
   begin
  delay 3.0;
  accept A;
  Ada.Text_IO.Put ("A");
   end A;
begin
   select
  A.A;
  Ada.Text_IO.Put ("B");
   then abort
  select
 A.A;
 Ada.Text_IO.Put ("C");
  then abort
 A.A;
  end select;
  Ada.Text_IO.Put ("D");
  A.A;
   end select;
end Example;

[Bug ada/118082] New: Types from other packages are not visible inside aggregate and reduction expressions inside generic bodies

2024-12-17 Thread liam at liampwll dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118082

Bug ID: 118082
   Summary: Types from other packages are not visible inside
aggregate and reduction expressions inside generic
bodies
   Product: gcc
   Version: 14.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: liam at liampwll dot com
CC: dkm at gcc dot gnu.org
  Target Milestone: ---

It appears that any types declared in other packages are not visible inside
aggregate and reduction expressions inside generic package bodies, but are
visible inside generic package specifications. This bug occurs on at least
13.3, 14.2, and mainline. This may be a duplicate of PR48039 but it is not
clear if this issue has the same cause.

Refer to the comments in the following code:

pragma Ada_2022;

procedure Tmp is
   package A is
  subtype T is Integer range 1..5;
   end A;

   package B is
  function F return Integer;
   end B;

   package body B is
  function F return Integer is
  begin
 if A.T'First < 3 then
return [for X in A.T => X]'Reduce ("+", 0);
--  No errors here, as expected.
 end if;
  end F;
   end B;

   generic package C is
  function F return Integer;
  function G return Integer is ([for X in A.T => X]'Reduce ("+", 0));
  --  No errors here, as expected.
   end C;

   package body C is
  function F return Integer is
  begin
 if A.T'First < 3 then
 --  A.T is visible above.
return [for X in A.T => X]'Reduce ("+", 0);
--  The above causes 'error: "A" is undefined'.
--  The same error occurs if we define F as an expression function.
 end if;
  end F;
   end C;

   package D is new C;
   --  If the package is not instantiated then no error is reported.
begin
   null;
end Tmp;

[Bug ada/118027] New: Real_Literal ans Integer_Literal aspects do not work for literals beginning with a sign

2024-12-13 Thread liam at liampwll dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118027

Bug ID: 118027
   Summary: Real_Literal ans Integer_Literal aspects do not work
for literals beginning with a sign
   Product: gcc
   Version: 14.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: liam at liampwll dot com
CC: dkm at gcc dot gnu.org
  Target Milestone: ---

As shown in the below code and error message, literals with signs are not
correctly handled. This bug is present in all versions since 11 where the
aspects were introduced.

   type T is null record with Integer_Literal => F;
   function F (Value : String) return T is (null record);
   A : T := 1;
   B : T := -1;
   C : T := +1;

example.adb:7:13: error: expected type "T" defined at line 4
example.adb:7:13: error: found type universal integer
example.adb:8:13: error: expected type "T" defined at line 4
example.adb:8:13: error: found type universal integer

[Bug ada/120430] New: Bogus formal object is not referenced

2025-05-25 Thread liam at liampwll dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120430

Bug ID: 120430
   Summary: Bogus formal object is not referenced
   Product: gcc
   Version: 14.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: liam at liampwll dot com
CC: dkm at gcc dot gnu.org
  Target Milestone: ---

[Bug ada/120430] Bogus "formal object is not referenced" when a generic parameter is used in a child package

2025-05-25 Thread liam at liampwll dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120430

--- Comment #1 from Liam Powell  ---
When a generic parameter of a package is used in a child package but not the
parent package a bogus warning is generated. Example below:

generic
   Foo : Integer;
package A is
end A;

generic
package A.B is
   function F return Integer is (Foo);
end A.B;

a.ads:2:04: warning: formal object "Foo" is not referenced [-gnatwu]

[Bug ada/120546] Array aggregate inside record aggregate inside generic package instantiation breaks Dimension_System

2025-06-04 Thread liam at liampwll dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120546

Liam Powell  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED

--- Comment #1 from Liam Powell  ---
After clicking back to my Compiler Explorer tab I noticed that I failed to
switch to trunk when testing. This seems to have been fixed already.

[Bug ada/120546] New: Array aggregate inside record aggregate inside generic package instantiation breaks Dimension_System

2025-06-04 Thread liam at liampwll dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120546

Bug ID: 120546
   Summary: Array aggregate inside record aggregate inside generic
package instantiation breaks Dimension_System
   Product: gcc
   Version: 14.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: liam at liampwll dot com
CC: dkm at gcc dot gnu.org
  Target Milestone: ---

The following code outputs `expected dimension [T], found []` even though the
dimension is clearly correct. It also does this even if a cast is used instead
of multiplication. This only occurs when a record aggregate, array aggregate,
and generic package instantiation are present, if any are removes then the code
compiles as expected.

pragma Ada_2022;

with System.Dim.Mks; use System.Dim.Mks;

procedure Tmp_Ada is
   type Rec is record
  T : Time;
   end record;

   type Arr is array (Boolean) of Rec;

   generic
  Foo : Arr;
   package Bar is
   end Bar;

   package My_Bar is new Bar ((others => (T => 1.0 * s)));
begin
   null;
end Tmp_Ada;

[Bug ada/121316] New: Representation clauses silently cause iterator filters to be ignored

2025-07-30 Thread liam at liampwll dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121316

Bug ID: 121316
   Summary: Representation clauses silently cause iterator filters
to be ignored
   Product: gcc
   Version: 16.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: liam at liampwll dot com
CC: dkm at gcc dot gnu.org
  Target Milestone: ---

The following code enters the loop in all cases despite the iterator filter.
This only occurs when the representation clause is present. This occurs on all
versions from 13.2 through to current trunk. 13.1 instead crashes. All versions
crash if `Use_Foo (F)'Image` is replaced with `Use_Foo'Image`.

procedure Example is
   type Foo is (A, B, C);
   for Foo use (A => 1, B => 2, C => 3);
   type Use_Foo_Type is array (Foo) of Boolean;
   Use_Foo : Use_Foo_Type := (A => True, B => False, C => True);
begin
   for F in Foo when Use_Foo (F) loop
  Put_Line (F'Image);
  Put_Line (Use_Foo (F)'Image);
   end loop;
end Example;