Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Men of peace usually are [brave]. -- Spock, "The Savage Curtain", stardate 5906.5


devel / comp.lang.ada / Compiler error (2) ?

SubjectAuthor
* Compiler error (2) ?reinert
+- Re: Compiler error (2) ?Simon Wright
`* Re: Compiler error (2) ?J-P. Rosen
 `* Re: Compiler error (2) ?reinert
  `- Re: Compiler error (2) ?reinert

1
Compiler error (2) ?

<7085edb5-688c-410c-b401-23ff3ca2a38fn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:5e49:0:b0:35b:b456:7261 with SMTP id i9-20020ac85e49000000b0035bb4567261mr17144040qtx.490.1664175273434;
Sun, 25 Sep 2022 23:54:33 -0700 (PDT)
X-Received: by 2002:a05:620a:1d02:b0:6ce:5820:2fdc with SMTP id
dl2-20020a05620a1d0200b006ce58202fdcmr13328880qkb.638.1664175273282; Sun, 25
Sep 2022 23:54:33 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Sun, 25 Sep 2022 23:54:33 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=84.209.88.37; posting-account=bPTmZAoAAAC_6HP9XLKB9aAAxBa6BuOR
NNTP-Posting-Host: 84.209.88.37
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7085edb5-688c-410c-b401-23ff3ca2a38fn@googlegroups.com>
Subject: Compiler error (2) ?
From: reinkor@gmail.com (reinert)
Injection-Date: Mon, 26 Sep 2022 06:54:33 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2139
 by: reinert - Mon, 26 Sep 2022 06:54 UTC

Hello,

This must reveal a compiler error :
-------------------------------------------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Containers.Vectors;
procedure test1a is
type s_name_type is (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
for s_name_type use
(S0 => 0, S1 => 1, S2 => 2, S3 => 3, S4 => 4,
S5 => 5, S6 => 6, S7 => 7, S8 => 8, S9 => 9);
package s_names_p is new Ada.Containers.Vectors
(Index_Type => Positive, Element_Type => s_name_type);
k : integer := 7;

-- n : constant integer := 7; -- uncomment this line and comment out the line below.
n : constant integer := k;

s_names: constant s_names_p.Vector := [for i in 3..n => S0];
begin
Ada.Text_IO.Put_Line(s_names'Image);
end test1a;
-------------------------------------------------------------------------------------------------------
(compiled using alire and
package Compiler is
for Switches ("ada") use ("-gnatwa", "-gnata", "-gnatX", "-gnatwv");
end Compiler;
-------------------------------------------------------------------------------------------------------

Right?

reinert

Re: Compiler error (2) ?

<lyedvy1rmy.fsf@pushface.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!Yr2L9qaRshuL+yFKTxsDBA.user.46.165.242.75.POSTED!not-for-mail
From: simon@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Re: Compiler error (2) ?
Date: Mon, 26 Sep 2022 09:12:05 +0100
Organization: Aioe.org NNTP Server
Message-ID: <lyedvy1rmy.fsf@pushface.org>
References: <7085edb5-688c-410c-b401-23ff3ca2a38fn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="62277"; posting-host="Yr2L9qaRshuL+yFKTxsDBA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (darwin)
Cancel-Lock: sha1:J+5Q9HsgC3mV9maFQ4NSEZkFfQk=
X-Notice: Filtered by postfilter v. 0.9.2
 by: Simon Wright - Mon, 26 Sep 2022 08:12 UTC

I'm not sure what compiler error you mean.

Agreed that the code as stands reports a strange issue,

11. S_Names: constant S_Names_P.Vector := [for I in 3..N => S0];
|
>>> error: expected type "Standard.Integer"
>>> error: found type "Ada.Containers.Count_Type"

which does look like a compiler error (even if it's only misreporting a
valid issue, I'm not sure).

What's more interesting is what happens if you make your suggested
change and it compiles. When you run it,

$ ./reinert_2

raised CONSTRAINT_ERROR : test1a.s_names_p.Replace_Element: Index is
out of range

Running this under the debugger, with 'catch exception',

Catchpoint 1, CONSTRAINT_ERROR (test1a.s_names_p.Replace_Element: Index is out of range) at 0x0000000100008ae5 in test1a () at reinert_2.adb:15
15 s_names: constant s_names_p.Vector := [for i in 3..n => S0];

So, what's Index?

(gdb) p index
No definition of "index" in current context.

Looing at the backtrace,

(gdb) bt
[...]
#4 0x0000000100011711 in test1a.s_names_p.replace_element (container=...,
index=6, new_item=s0)
at /opt/gcc-12.1.0/lib/gcc/x86_64-apple-darwin15/12.1.0/adainclude/a-convec.adb:2522
#5 0x0000000100008ae5 in test1a () at reinert_2.adb:15

Frame 4 is in the runtime; maybe we can see what's going on,

(gdb) fr 4
#4 0x0000000100011711 in test1a.s_names_p.replace_element (container=...,
index=6, new_item=s0)
at /opt/gcc-12.1.0/lib/gcc/x86_64-apple-darwin15/12.1.0/adainclude/a-convec.adb:2522
2522 raise Constraint_Error with "Index is out of range";
(gdb) p index
$1 = 6

Hmm. What does the source say?

(gdb) l
2517 is
2518 begin
2519 TE_Check (Container.TC);
2520
2521 if Checks and then Index > Container.Last then
2522 raise Constraint_Error with "Index is out of range";
2523 end if;
2524
2525 Container.Elements.EA (Index) := New_Item;
2526 end Replace_Element;

So Index (6) is more than Container.Last:

(gdb) p container
$2 = (elements => 0x600000008000, last => 5, tc => (busy => 0, lock => 0))
(gdb)

6 is certainly more than 5. Where does 5 come from?

Index is Positive. We were hoping to have our container with indices
supporting values up to 7, but the first index of a container has to be
Index_Type'First i.e. 1; the compiler has looked at the length of the
aggregate (5) and created an empty Vector s_names of that length.

Clearly you can't do slices in this context!

Re: Compiler error (2) ?

<tgro67$3mod2$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: rosen@adalog.fr (J-P. Rosen)
Newsgroups: comp.lang.ada
Subject: Re: Compiler error (2) ?
Date: Mon, 26 Sep 2022 10:34:19 +0200
Organization: Adalog
Lines: 45
Message-ID: <tgro67$3mod2$1@dont-email.me>
References: <7085edb5-688c-410c-b401-23ff3ca2a38fn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 26 Sep 2022 08:34:15 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="e8a32e2defd05dbfb7071d879f1df9fc";
logging-data="3891618"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Xf0VkYMgeNgGP+oRRFYJ2"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.2.1
Cancel-Lock: sha1:uL0/I950yi0Cdk5XWNy5ZPTN6gQ=
In-Reply-To: <7085edb5-688c-410c-b401-23ff3ca2a38fn@googlegroups.com>
Content-Language: fr
 by: J-P. Rosen - Mon, 26 Sep 2022 08:34 UTC

Please give the exact error message, and why you think it could be a
compiler error. Otherwise, it's hard to help...

Le 26/09/2022 à 08:54, reinert a écrit :
> Hello,
>
> This must reveal a compiler error :
> -------------------------------------------------------------------------------------------------------
> with Ada.Text_IO;
> with Ada.Containers.Vectors;
> procedure test1a is
> type s_name_type is (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
> for s_name_type use
> (S0 => 0, S1 => 1, S2 => 2, S3 => 3, S4 => 4,
> S5 => 5, S6 => 6, S7 => 7, S8 => 8, S9 => 9);
> package s_names_p is new Ada.Containers.Vectors
> (Index_Type => Positive, Element_Type => s_name_type);
> k : integer := 7;
>
> -- n : constant integer := 7; -- uncomment this line and comment out the line below.
> n : constant integer := k;
>
> s_names: constant s_names_p.Vector := [for i in 3..n => S0];
> begin
> Ada.Text_IO.Put_Line(s_names'Image);
> end test1a;
> -------------------------------------------------------------------------------------------------------
> (compiled using alire and
> package Compiler is
> for Switches ("ada") use ("-gnatwa", "-gnata", "-gnatX", "-gnatwv");
> end Compiler;
> -------------------------------------------------------------------------------------------------------
>
> Right?
>
> reinert

--
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52
https://www.adalog.fr

Re: Compiler error (2) ?

<4f8e27ad-03d7-400f-9901-92856e71f9d2n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:6214:3006:b0:496:ad87:6784 with SMTP id ke6-20020a056214300600b00496ad876784mr16303592qvb.7.1664182034475;
Mon, 26 Sep 2022 01:47:14 -0700 (PDT)
X-Received: by 2002:ac8:5cc1:0:b0:35c:eba0:bc37 with SMTP id
s1-20020ac85cc1000000b0035ceba0bc37mr16676551qta.638.1664182034227; Mon, 26
Sep 2022 01:47:14 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Mon, 26 Sep 2022 01:47:13 -0700 (PDT)
In-Reply-To: <tgro67$3mod2$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=84.209.88.37; posting-account=bPTmZAoAAAC_6HP9XLKB9aAAxBa6BuOR
NNTP-Posting-Host: 84.209.88.37
References: <7085edb5-688c-410c-b401-23ff3ca2a38fn@googlegroups.com> <tgro67$3mod2$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4f8e27ad-03d7-400f-9901-92856e71f9d2n@googlegroups.com>
Subject: Re: Compiler error (2) ?
From: reinkor@gmail.com (reinert)
Injection-Date: Mon, 26 Sep 2022 08:47:14 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4382
 by: reinert - Mon, 26 Sep 2022 08:47 UTC

This is what I (also) get:

test1a.adb:16:42: error: expected type "Standard.Integer"
test1a.adb:16:42: error: found type "Ada.Containers.Count_Type"

compilation of test1a.adb failed

gprbuild: *** compilation phase failed
error: Command ["gprbuild", "-s", "-j0", "-p", "-P", "/home/reinert/test1a/test1a.gpr"] exited with code 4
error: Compilation failed.
---------------------------------------------------------------------------------------------------
**However, the following version goes through the compiler and runs
(using "subtype n_t is Positive range 3..Positive'Last;" for)
in the package specification) - confirming what Simon says:

with Ada.Text_IO;
with Ada.Containers.Vectors;
procedure test1a is
type s_name_type is (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
for s_name_type use
(S0 => 0, S1 => 1, S2 => 2, S3 => 3, S4 => 4,
S5 => 5, S6 => 6, S7 => 7, S8 => 8, S9 => 9);
subtype n_t is Positive range 3..Positive'Last;
package s_names_p is new Ada.Containers.Vectors
(Index_Type => n_t, Element_Type => s_name_type);
k : integer := 7;

n : constant integer := 7;
-- n : constant integer := k; -- uncomment this line and comment out the line above.

s_names: constant s_names_p.Vector := [for i in 3..n => S0];
begin
Ada.Text_IO.Put_Line(s_names'Image);
end test1a;

reinert

mandag 26. september 2022 kl. 10:34:18 UTC+2 skrev J-P. Rosen:
> Please give the exact error message, and why you think it could be a
> compiler error. Otherwise, it's hard to help...
> Le 26/09/2022 à 08:54, reinert a écrit :
> > Hello,
> >
> > This must reveal a compiler error :
> > -------------------------------------------------------------------------------------------------------
> > with Ada.Text_IO;
> > with Ada.Containers.Vectors;
> > procedure test1a is
> > type s_name_type is (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
> > for s_name_type use
> > (S0 => 0, S1 => 1, S2 => 2, S3 => 3, S4 => 4,
> > S5 => 5, S6 => 6, S7 => 7, S8 => 8, S9 => 9);
> > package s_names_p is new Ada.Containers.Vectors
> > (Index_Type => Positive, Element_Type => s_name_type);
> > k : integer := 7;
> >
> > -- n : constant integer := 7; -- uncomment this line and comment out the line below.
> > n : constant integer := k;
> >
> > s_names: constant s_names_p.Vector := [for i in 3..n => S0];
> > begin
> > Ada.Text_IO.Put_Line(s_names'Image);
> > end test1a;
> > -------------------------------------------------------------------------------------------------------
> > (compiled using alire and
> > package Compiler is
> > for Switches ("ada") use ("-gnatwa", "-gnata", "-gnatX", "-gnatwv");
> > end Compiler;
> > -------------------------------------------------------------------------------------------------------
> >
> > Right?
> >
> > reinert
> --
> J-P. Rosen
> Adalog
> 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
> Tel: +33 1 45 29 21 52
> https://www.adalog.fr

Re: Compiler error (2) ?

<734dd652-f1e4-438c-900e-021cdadc3edcn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:b88:b0:6ce:ec98:e7f8 with SMTP id k8-20020a05620a0b8800b006ceec98e7f8mr13910333qkh.338.1664186364924;
Mon, 26 Sep 2022 02:59:24 -0700 (PDT)
X-Received: by 2002:ac8:7dc6:0:b0:35c:c9b1:9f98 with SMTP id
c6-20020ac87dc6000000b0035cc9b19f98mr17442740qte.170.1664186364714; Mon, 26
Sep 2022 02:59:24 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Mon, 26 Sep 2022 02:59:24 -0700 (PDT)
In-Reply-To: <4f8e27ad-03d7-400f-9901-92856e71f9d2n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=84.209.88.37; posting-account=bPTmZAoAAAC_6HP9XLKB9aAAxBa6BuOR
NNTP-Posting-Host: 84.209.88.37
References: <7085edb5-688c-410c-b401-23ff3ca2a38fn@googlegroups.com>
<tgro67$3mod2$1@dont-email.me> <4f8e27ad-03d7-400f-9901-92856e71f9d2n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <734dd652-f1e4-438c-900e-021cdadc3edcn@googlegroups.com>
Subject: Re: Compiler error (2) ?
From: reinkor@gmail.com (reinert)
Injection-Date: Mon, 26 Sep 2022 09:59:24 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4795
 by: reinert - Mon, 26 Sep 2022 09:59 UTC

Sorry for some typos in my latest post, but the intelligent reader should understand :-)

reinert

mandag 26. september 2022 kl. 10:47:16 UTC+2 skrev reinert:
> This is what I (also) get:
>
> test1a.adb:16:42: error: expected type "Standard.Integer"
> test1a.adb:16:42: error: found type "Ada.Containers.Count_Type"
>
> compilation of test1a.adb failed
>
> gprbuild: *** compilation phase failed
> error: Command ["gprbuild", "-s", "-j0", "-p", "-P", "/home/reinert/test1a/test1a.gpr"] exited with code 4
> error: Compilation failed.
> ---------------------------------------------------------------------------------------------------
> **However, the following version goes through the compiler and runs
> (using "subtype n_t is Positive range 3..Positive'Last;" for)
> in the package specification) - confirming what Simon says:
>
> with Ada.Text_IO;
> with Ada.Containers.Vectors;
> procedure test1a is
> type s_name_type is (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
> for s_name_type use
> (S0 => 0, S1 => 1, S2 => 2, S3 => 3, S4 => 4,
> S5 => 5, S6 => 6, S7 => 7, S8 => 8, S9 => 9);
> subtype n_t is Positive range 3..Positive'Last;
> package s_names_p is new Ada.Containers.Vectors
> (Index_Type => n_t, Element_Type => s_name_type);
> k : integer := 7;
> n : constant integer := 7;
> -- n : constant integer := k; -- uncomment this line and comment out the line above.
> s_names: constant s_names_p.Vector := [for i in 3..n => S0];
> begin
> Ada.Text_IO.Put_Line(s_names'Image);
> end test1a;
> reinert
> mandag 26. september 2022 kl. 10:34:18 UTC+2 skrev J-P. Rosen:
> > Please give the exact error message, and why you think it could be a
> > compiler error. Otherwise, it's hard to help...
> > Le 26/09/2022 à 08:54, reinert a écrit :
> > > Hello,
> > >
> > > This must reveal a compiler error :
> > > -------------------------------------------------------------------------------------------------------
> > > with Ada.Text_IO;
> > > with Ada.Containers.Vectors;
> > > procedure test1a is
> > > type s_name_type is (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
> > > for s_name_type use
> > > (S0 => 0, S1 => 1, S2 => 2, S3 => 3, S4 => 4,
> > > S5 => 5, S6 => 6, S7 => 7, S8 => 8, S9 => 9);
> > > package s_names_p is new Ada.Containers.Vectors
> > > (Index_Type => Positive, Element_Type => s_name_type);
> > > k : integer := 7;
> > >
> > > -- n : constant integer := 7; -- uncomment this line and comment out the line below.
> > > n : constant integer := k;
> > >
> > > s_names: constant s_names_p.Vector := [for i in 3..n => S0];
> > > begin
> > > Ada.Text_IO.Put_Line(s_names'Image);
> > > end test1a;
> > > -------------------------------------------------------------------------------------------------------
> > > (compiled using alire and
> > > package Compiler is
> > > for Switches ("ada") use ("-gnatwa", "-gnata", "-gnatX", "-gnatwv");
> > > end Compiler;
> > > -------------------------------------------------------------------------------------------------------
> > >
> > > Right?
> > >
> > > reinert
> > --
> > J-P. Rosen
> > Adalog
> > 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
> > Tel: +33 1 45 29 21 52
> > https://www.adalog.fr


devel / comp.lang.ada / Compiler error (2) ?

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor