comp.lang.ada
 help / color / mirror / Atom feed
* Confused error message - GNAT GPL 2017
@ 2020-03-12  7:02 Jesper Quorning
  2020-03-12  8:02 ` Egil H H
  2020-03-12  8:15 ` Nicolas
  0 siblings, 2 replies; 4+ messages in thread
From: Jesper Quorning @ 2020-03-12  7:02 UTC (permalink / raw)


Greetings,

Normally the GNAT compiler gives good and informative error messages, 
in this case however not so much.

While experimenting with iterating a data structure I got this error message:

test.adb:5:15: "" is undefined
test.adb:5:15: subtype mark required in this context
test.adb:5:15: found <empty> declared at unknown location
test.adb:5:15: invalid prefix in call
test.adb:5:15: invalid prefix in selected component “I3b"

Located at the loop keyword in:

with Containers;
procedure Test is
   C : Containers.Container;
begin
   for E of C loop
      null;
   end loop;
end Test;

The Containers spec I valid (it compiles):

package Containers is

   type Container is tagged null record
     with
       Variable_Indexing => Reference,
       Iterator_Element  => Integer;

   function Element (C : Container; Index : Integer) return Integer;

   type Reference_Type (Element : not null access Integer) is null record
     with Implicit_Dereference => Element;

   function Reference (C : aliased in out Container; Index : Integer)
                      return Reference_Type;

end Containers;

I use GNAT GPL 2017. Is this odd error message still present in an up-to-date GNAT?


Thanks,
Jesper

—
Give me a Cool Corona !

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Confused error message - GNAT GPL 2017
  2020-03-12  7:02 Confused error message - GNAT GPL 2017 Jesper Quorning
@ 2020-03-12  8:02 ` Egil H H
  2020-03-12 15:44   ` Simon Wright
  2020-03-12  8:15 ` Nicolas
  1 sibling, 1 reply; 4+ messages in thread
From: Egil H H @ 2020-03-12  8:02 UTC (permalink / raw)


On Thursday, March 12, 2020 at 8:02:30 AM UTC+1, Jesper Quorning wrote:
> 
> While experimenting with iterating a data structure I got this error message:
> 
> test.adb:5:15: "" is undefined
> test.adb:5:15: subtype mark required in this context
> test.adb:5:15: found <empty> declared at unknown location
> test.adb:5:15: invalid prefix in call
> test.adb:5:15: invalid prefix in selected component “I3b"
> 
> 
> I use GNAT GPL 2017. Is this odd error message still present in an up-to-date GNAT?
> 


While the error message may look odd (gnat pro 20 gives a better one;
test.adb:5:08: cannot iterate over "Container"), the "for E of C loop" construct depends on the Default_Iterator aspect, which is missing 
for your Container type. I suspect that is the root cause of the error.

-- 
~egilhh

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Confused error message - GNAT GPL 2017
  2020-03-12  7:02 Confused error message - GNAT GPL 2017 Jesper Quorning
  2020-03-12  8:02 ` Egil H H
@ 2020-03-12  8:15 ` Nicolas
  1 sibling, 0 replies; 4+ messages in thread
From: Nicolas @ 2020-03-12  8:15 UTC (permalink / raw)


Hi,


Le 12/03/2020 à 08:02, Jesper Quorning a écrit :
> Greetings,
> 
> Normally the GNAT compiler gives good and informative error messages,
> in this case however not so much.
> 
> While experimenting with iterating a data structure I got this error message:
> 
> test.adb:5:15: "" is undefined
> test.adb:5:15: subtype mark required in this context
> test.adb:5:15: found <empty> declared at unknown location
> test.adb:5:15: invalid prefix in call
> test.adb:5:15: invalid prefix in selected component “I3b"
> 
> Located at the loop keyword in:
> 
> with Containers;
> procedure Test is
>     C : Containers.Container;
> begin
>     for E of C loop
>        null;
>     end loop;
> end Test;
> 
> The Containers spec I valid (it compiles):
> 
> package Containers is
> 
>     type Container is tagged null record
>       with
>         Variable_Indexing => Reference,
>         Iterator_Element  => Integer;
> 
>     function Element (C : Container; Index : Integer) return Integer;
> 
>     type Reference_Type (Element : not null access Integer) is null record
>       with Implicit_Dereference => Element;
> 
>     function Reference (C : aliased in out Container; Index : Integer)
>                        return Reference_Type;
> 
> end Containers;
> 
> I use GNAT GPL 2017. Is this odd error message still present in an up-to-date GNAT?
> 

I tried with last GNAT community version (20190517-83) whith
Ada 2012 switch activated.
Here is the run output :

gprbuild -d -PZ:\ADA_tests\test2\default.gpr Z:\ADA_tests\test2\src\main.adb
"Z:\ADA_tests\test2\obj\main.adb.stdout" has been deleted
"Z:\ADA_tests\test2\obj\main.adb.stderr" has been deleted
Warning: "Z:\ADA_tests\test2\obj\gnatinspect.db" could not be deleted
Warning: "Z:\ADA_tests\test2\obj\gnatinspect.db-shm" could not be deleted
Warning: "Z:\ADA_tests\test2\obj\gnatinspect.db-wal" could not be deleted
[2020-03-12 09:08:33] process terminated successfully, elapsed time: 08.04s
Compile
    [Ada]          main.adb
+===========================GNAT BUG DETECTED==============================+
| Community 2019 (20190517-83) (x86_64-pc-mingw32) Program_Error 
EXCEPTION_ACCESS_VIOLATION|
| Error detected at main.adb:5:15                                          |
| Please submit a bug report by email to report@adacore.com.               |
| GAP members can alternatively use GNAT Tracker:                          |
| http://www.adacore.com/ section 'send a report'.                         |
| See gnatinfo.txt for full info on procedure for submitting 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.                                       |
| Use plain ASCII or MIME attachment(s).                                   |
+==========================================================================+

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

Z:\ADA_tests\test2\src\main.adb
Z:\ADA_tests\test2\src\containers.ads

compilation abandoned
gprbuild: *** compilation phase failed
[2020-03-12 09:08:39] process exited with status 4, elapsed time: 08.64s

Nicolas

> 
> Thanks,
> Jesper
> 
> —
> Give me a Cool Corona !
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Confused error message - GNAT GPL 2017
  2020-03-12  8:02 ` Egil H H
@ 2020-03-12 15:44   ` Simon Wright
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Wright @ 2020-03-12 15:44 UTC (permalink / raw)


Egil H H <ehh.public@gmail.com> writes:

> On Thursday, March 12, 2020 at 8:02:30 AM UTC+1, Jesper Quorning wrote:
>>
>> While experimenting with iterating a data structure I got this error
>> message:
>>
>> test.adb:5:15: "" is undefined
>> test.adb:5:15: subtype mark required in this context
>> test.adb:5:15: found <empty> declared at unknown location
>> test.adb:5:15: invalid prefix in call
>> test.adb:5:15: invalid prefix in selected component “I3b"
>>
>>
>> I use GNAT GPL 2017. Is this odd error message still present in an
>> up-to-date GNAT?
>>
> While the error message may look odd (gnat pro 20 gives a better one;
> test.adb:5:08: cannot iterate over "Container"), the "for E of C loop"
> construct depends on the Default_Iterator aspect, which is missing
> for your Container type. I suspect that is the root cause of the error.

GCC 10.0.1 gives the same improved error with your source as-is.
GNAT CE 2019 likewise if you remove the Iterator_Element aspect.
But of course what you need is Default_Iterator, as Egil says.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-03-12 15:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-12  7:02 Confused error message - GNAT GPL 2017 Jesper Quorning
2020-03-12  8:02 ` Egil H H
2020-03-12 15:44   ` Simon Wright
2020-03-12  8:15 ` Nicolas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox