Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

LOAD "LINUX",8,1 -- Topic on #LinuxGER


devel / comp.lang.ada / Generic formal ">"

SubjectAuthor
* Generic formal ">"Simon Wright
+- Re: Generic formal ">"Jeffrey R.Carter
`* Re: Generic formal ">"AdaMagica
 `* Re: Generic formal ">"AdaMagica
  `- Re: Generic formal ">"Simon Wright

1
Generic formal ">"

<lymtjisahx.fsf@pushface.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6562&group=comp.lang.ada#6562

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!8nKyDL3nVTTIdBB8axZhRA.user.46.165.242.75.POSTED!not-for-mail
From: sim...@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Generic formal ">"
Date: Wed, 26 Jan 2022 16:54:50 +0000
Organization: Aioe.org NNTP Server
Message-ID: <lymtjisahx.fsf@pushface.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="42893"; posting-host="8nKyDL3nVTTIdBB8axZhRA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin)
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:+P1ds/s1LpHTUa+osQ88zQFLzBk=
 by: Simon Wright - Wed, 26 Jan 2022 16:54 UTC

I have a generic with a formal private type Element_Type and a formal
function ">" (L, R : Element_Type) return Boolean. This gives me
puzzling and compiler-dependent behaviour when I instantiate with
">" => "<".

The output from the code below is

GCC 10.1.0:

Data'Length: 2
Data'Length > 1: TRUE
Integer'(Data'Length) > 1: TRUE
Standard.">" (Data'Length, 1): TRUE
Standard.">" (Integer'(Data'Length), 1): TRUE

GCC 11.1.0:

Data'Length: 2
Data'Length > 1: FALSE
Integer'(Data'Length) > 1: TRUE
Standard.">" (Data'Length, 1): FALSE
Standard.">" (Integer'(Data'Length), 1): TRUE

I don't know what version of ">" will be used when the unqualified
Data'Length is involved, but I would have expected that the overridden
("<") version would be used in the Integer'(Data'Length)
version. (Sorry, I don't think overridden is the right word).

GCC 10 uses the version from package standard even when given
integer-qualified data.

GCC 11 uses the version from package standard when given
integer-qualified data, and the overriding version when not.

Is it right that Standard.">" is getting overridden?

Have the rules changed in this area?

My "fix" was to compare Data'Length >= 2!

8X-------------------
with Ada.Text_IO; use Ada.Text_IO;
procedure Gen_Cmp is
generic
type Element_Type is private;
type Index_Type is (<>);
type Array_Type is array (Index_Type range <>) of Element_Type;
with function ">" (Left, Right : Element_Type) return Boolean is <>;
procedure Gen (Data: in out Array_Type);

procedure Gen (Data: in out Array_Type) is
begin
Put_Line ("Data'Length:" & Data'Length'Image);
Put_Line ("Data'Length > 1: "
& Boolean'Image (Data'Length > 1));
Put_Line ("Integer'(Data'Length) > 1: "
& Boolean'Image (Integer'(Data'Length) > 1));
Put_Line ("Standard."">"" (Data'Length, 1): "
& Boolean'Image (Standard.">" (Data'Length, 1)));
Put_Line ("Standard."">"" (Integer'(Data'Length), 1): "
& Boolean'Image (Standard.">" (Integer'(Data'Length), 1)));
end Gen;

type Alpha is
(A, B, C, D, E, F, G, H, I, J, K, L, M,
N, O, P, Q, R, S, T, U, V, W, X, Y, Z);

type My_Array is array (Alpha range <>) of Integer;

procedure Chk_Down is new Gen (Element_Type => Integer,
Index_Type => Alpha,
Array_Type => My_Array,
">" => "<");

Data : My_Array (A .. B);
begin
Chk_Down (Data);
end Gen_Cmp;

Re: Generic formal ">"

<sss4te$soa$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6563&group=comp.lang.ada#6563

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: spam.jrc...@spam.acm.org.not (Jeffrey R.Carter)
Newsgroups: comp.lang.ada
Subject: Re: Generic formal ">"
Date: Wed, 26 Jan 2022 19:46:06 +0100
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <sss4te$soa$1@dont-email.me>
References: <lymtjisahx.fsf@pushface.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 26 Jan 2022 18:46:06 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="1625313f3f97c0ea2ade76c1ca82823f";
logging-data="29450"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18wGXRtmsbiAizyJl/lyF6tQzbSGIZ60RU="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Cancel-Lock: sha1:y2yiBslOeRYDSwZilhisb/W67i0=
In-Reply-To: <lymtjisahx.fsf@pushface.org>
Content-Language: en-US
 by: Jeffrey R.Carter - Wed, 26 Jan 2022 18:46 UTC

On 2022-01-26 17:54, Simon Wright wrote:
>
> GCC 10.1.0:
>
> Data'Length: 2
> Data'Length > 1: TRUE
> Integer'(Data'Length) > 1: TRUE
> Standard.">" (Data'Length, 1): TRUE
> Standard.">" (Integer'(Data'Length), 1): TRUE
>
> GCC 11.1.0:
>
> Data'Length: 2
> Data'Length > 1: FALSE
> Integer'(Data'Length) > 1: TRUE
> Standard.">" (Data'Length, 1): FALSE
> Standard.">" (Integer'(Data'Length), 1): TRUE

This looks like an error introduced in V11. 'Length is universal_integer, which
has no primitive subprograms. Within the generic, Element_Type and Integer are
distinct types, and Element_Type is not a numeric type. So Data'Length should
not be converted to Element_Type, and the ">" defined for Element_Type should
not be invoked. This is also true for Integer'(Data'Length).

--
Jeff Carter
"Son of a window-dresser."
Monty Python & the Holy Grail
12

Re: Generic formal ">"

<3ecb1915-5e53-40bd-aaba-96ac52e774b1n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6564&group=comp.lang.ada#6564

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:622a:44e:: with SMTP id o14mr21879490qtx.669.1643222936879;
Wed, 26 Jan 2022 10:48:56 -0800 (PST)
X-Received: by 2002:a25:dfc7:: with SMTP id w190mr365865ybg.696.1643222936747;
Wed, 26 Jan 2022 10:48:56 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 26 Jan 2022 10:48:56 -0800 (PST)
In-Reply-To: <lymtjisahx.fsf@pushface.org>
Injection-Info: google-groups.googlegroups.com; posting-host=94.31.100.23; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf
NNTP-Posting-Host: 94.31.100.23
References: <lymtjisahx.fsf@pushface.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3ecb1915-5e53-40bd-aaba-96ac52e774b1n@googlegroups.com>
Subject: Re: Generic formal ">"
From: christ-u...@t-online.de (AdaMagica)
Injection-Date: Wed, 26 Jan 2022 18:48:56 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 1
 by: AdaMagica - Wed, 26 Jan 2022 18:48 UTC

Within the generic, data'length is an integer value of type universal integer. This has nothing to do with the generic parameter Element_Type, even if this is instantiated with Integer.
The predefined attribute 'Image produces a string from parameter Integer. So Data'Length is implicitly converted from universal_integer to integer. This is independent from the generic parameter Element_Type.

Re: Generic formal ">"

<2c201046-a0f0-48aa-a8a1-f177d5349e45n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6565&group=comp.lang.ada#6565

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ad4:5f89:: with SMTP id jp9mr311886qvb.130.1643223622502;
Wed, 26 Jan 2022 11:00:22 -0800 (PST)
X-Received: by 2002:a25:2d43:: with SMTP id s3mr466418ybe.646.1643223622340;
Wed, 26 Jan 2022 11:00:22 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 26 Jan 2022 11:00:22 -0800 (PST)
In-Reply-To: <3ecb1915-5e53-40bd-aaba-96ac52e774b1n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=94.31.100.23; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf
NNTP-Posting-Host: 94.31.100.23
References: <lymtjisahx.fsf@pushface.org> <3ecb1915-5e53-40bd-aaba-96ac52e774b1n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2c201046-a0f0-48aa-a8a1-f177d5349e45n@googlegroups.com>
Subject: Re: Generic formal ">"
From: christ-u...@t-online.de (AdaMagica)
Injection-Date: Wed, 26 Jan 2022 19:00:22 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 7
 by: AdaMagica - Wed, 26 Jan 2022 19:00 UTC

GNAT CE 2021 produces the wrong result. You should definitely report this.

Data'Length: 2
Data'Length > 1: FALSE
Integer'(Data'Length) > 1: TRUE
Standard.">" (Data'Length, 1): FALSE
Standard.">" (Integer'(Data'Length), 1): TRUE
[2022-01-26 19:53:10] process terminated successfully, elapsed time: 02.39s

Re: Generic formal ">"

<lyilu5s7sg.fsf@pushface.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6566&group=comp.lang.ada#6566

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!8nKyDL3nVTTIdBB8axZhRA.user.46.165.242.75.POSTED!not-for-mail
From: sim...@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Re: Generic formal ">"
Date: Thu, 27 Jan 2022 12:05:35 +0000
Organization: Aioe.org NNTP Server
Message-ID: <lyilu5s7sg.fsf@pushface.org>
References: <lymtjisahx.fsf@pushface.org>
<3ecb1915-5e53-40bd-aaba-96ac52e774b1n@googlegroups.com>
<2c201046-a0f0-48aa-a8a1-f177d5349e45n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="17455"; posting-host="8nKyDL3nVTTIdBB8axZhRA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin)
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:HLeKivxwSbs0smtFUEZkEUL+udg=
 by: Simon Wright - Thu, 27 Jan 2022 12:05 UTC

AdaMagica <christ-usch.grein@t-online.de> writes:

> GNAT CE 2021 produces the wrong result. You should definitely report this.

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

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor