[Bug ada/108157] New: [12/13 regression] object subtype doesn't statically match designated subtype

simon at pushface dot org gcc-bugzilla@gcc.gnu.org
Sat Dec 17 20:00:26 GMT 2022


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

            Bug ID: 108157
           Summary: [12/13 regression] object subtype doesn't statically
                    match designated subtype
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: simon at pushface dot org
                CC: dkm at gcc dot gnu.org
  Target Milestone: ---

Created attachment 54118
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54118&action=edit
Demonstrator

The attached code fails with

   $ /opt/gcc-12.2.0/bin/gcc -c g-socser.adb
   g-socser.adb:13:22: error: object subtype must statically match designated
subtype

The relevant part of g-socser.adb:

     9.       Connect_Socket
    10.         (Socket   => Client.Socket,
    11.          Server   => Client.Client_Address,
    12.          Timeout  => 0.0,
    13.          Selector => Listener.Selector'Unchecked_Access,
                             |
        >>> error: object subtype must statically match designated subtype

The relevant part of g-socser.ads:

    20.    type Connections_Server is tagged limited record
    21.       --  limited because Selector_Type is limited
    22.       Selector : aliased Selector_Type;
    23.    end record;

The relevant part of the GNAT standard library GNAT.Sockets is

   procedure Connect_Socket
     (Socket   : Socket_Type;
      Server   : Sock_Addr_Type;
      Timeout  : Selector_Duration;
      Selector : access Selector_Type := null;
      Status   : out Selector_Status);

and it’s the same Selector_Type all the way.

I’ve looked at Annotated Ada Reference Manual (Ada 2022 Draft 34) 4.9.1[1] and
I can’t see what the problem is.

Note, I don’t know why the code uses 'Unchecked_Access; 'Access gives the same
error, 'Unrestricted_Access compiles OK.

[1] http://www.ada-auth.org/standards/22aarm/html/AA-4-9-1.html


More information about the Gcc-bugs mailing list