comp.lang.ada
 help / color / mirror / Atom feed
* GNAT Error?
@ 2024-02-16 22:51 Jeffrey R.Carter
  2024-02-16 23:26 ` Niklas Holsti
  0 siblings, 1 reply; 11+ messages in thread
From: Jeffrey R.Carter @ 2024-02-16 22:51 UTC (permalink / raw)


I have this code:

package Alloc_Err is
    type RT is record
       F1 : Integer;
       F2 : Integer;
    end record;

    type Grid is array (Positive range <>, Positive range <>) of RT with
       Dynamic_Predicate => Grid'First (1) = 1 and Grid'First (2) = 1;

    procedure What;
end Alloc_Err;

package Alloc_Err is
    type RT is record
       F1 : Integer;
       F2 : Integer;
    end record;

    type Grid is array (Positive range <>, Positive range <>) of RT with
       Dynamic_Predicate => Grid'First (1) = 1 and Grid'First (2) = 1;

    procedure What;
end Alloc_Err;

and GNAT 12.3.0 and 13.2.0 say

alloc_err.adb:5:26: error: invalid use of subtype mark in expression or call

This doesn't happen if the Dynamic_Predicate is removed. This looks like an 
error to me, but I thought I'd better see if there's something I've missed.

-- 
Jeff Carter
"I like it when the support group complains that they have
insufficient data on mean time to repair bugs in Ada software."
Robert I. Eachus
91

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

* Re: GNAT Error?
  2024-02-16 22:51 GNAT Error? Jeffrey R.Carter
@ 2024-02-16 23:26 ` Niklas Holsti
  2024-02-16 23:45   ` Jeffrey R.Carter
  0 siblings, 1 reply; 11+ messages in thread
From: Niklas Holsti @ 2024-02-16 23:26 UTC (permalink / raw)


On 2024-02-17 0:51, Jeffrey R.Carter wrote:
> I have this code:
> 
> package Alloc_Err is
>     type RT is record
>        F1 : Integer;
>        F2 : Integer;
>     end record;
> 
>     type Grid is array (Positive range <>, Positive range <>) of RT with
>        Dynamic_Predicate => Grid'First (1) = 1 and Grid'First (2) = 1;
> 
>     procedure What;
> end Alloc_Err;
> 
> package Alloc_Err is
>     type RT is record
>        F1 : Integer;
>        F2 : Integer;
>     end record;
> 
>     type Grid is array (Positive range <>, Positive range <>) of RT with
>        Dynamic_Predicate => Grid'First (1) = 1 and Grid'First (2) = 1;
> 
>     procedure What;
> end Alloc_Err;
> 
> and GNAT 12.3.0 and 13.2.0 say
> 
> alloc_err.adb:5:26: error: invalid use of subtype mark in expression or 
> call
> 
> This doesn't happen if the Dynamic_Predicate is removed. This looks like 
> an error to me, but I thought I'd better see if there's something I've 
> missed.


You showed two copies of the declaration (spec) of package Alloc_Err, 
but you did not show the body of the package. Based on the error message 
pointing to alloc_err.adb (and not .ads), GNAT thinks the error is in 
the body. Please show the body of the package.

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

* Re: GNAT Error?
  2024-02-16 23:26 ` Niklas Holsti
@ 2024-02-16 23:45   ` Jeffrey R.Carter
  2024-02-17  6:04     ` Randy Brukardt
  0 siblings, 1 reply; 11+ messages in thread
From: Jeffrey R.Carter @ 2024-02-16 23:45 UTC (permalink / raw)


On 2024-02-17 00:26, Niklas Holsti wrote:
> 
> You showed two copies of the declaration (spec) of package Alloc_Err, but you 
> did not show the body of the package. Based on the error message pointing to 
> alloc_err.adb (and not .ads), GNAT thinks the error is in the body. Please show 
> the body of the package.
> 

Oops. Well, I've managed to simplify the reproducer to

procedure Alloc2 is
    type Grid is array (Positive range <>, Positive range <>) of Integer with
       Dynamic_Predicate => Grid'First (1) = 1 and Grid'First (2) = 1;

    type Grid_Ptr is access Grid;

    Data : Grid_Ptr := new Grid (1 .. 10, 1 .. 20);
begin -- Alloc2
    null;
end Alloc2;

which results in

alloc2.adb:7:23: error: invalid use of subtype mark in expression or call

Line 7 is the declaration of Data.

-- 
Jeff Carter
"I like it when the support group complains that they have
insufficient data on mean time to repair bugs in Ada software."
Robert I. Eachus
91

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

* Re: GNAT Error?
  2024-02-16 23:45   ` Jeffrey R.Carter
@ 2024-02-17  6:04     ` Randy Brukardt
  2024-02-17  6:11       ` Jeffrey R.Carter
  0 siblings, 1 reply; 11+ messages in thread
From: Randy Brukardt @ 2024-02-17  6:04 UTC (permalink / raw)


I don't see anything wrong with that off-hand. It's probably a compiler bug 
of some sort. - Randy.


"Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not> wrote in message 
news:uqos24$3rue0$2@dont-email.me...
> On 2024-02-17 00:26, Niklas Holsti wrote:
>>
>> You showed two copies of the declaration (spec) of package Alloc_Err, but 
>> you did not show the body of the package. Based on the error message 
>> pointing to alloc_err.adb (and not .ads), GNAT thinks the error is in the 
>> body. Please show the body of the package.
>>
>
> Oops. Well, I've managed to simplify the reproducer to
>
> procedure Alloc2 is
>    type Grid is array (Positive range <>, Positive range <>) of Integer 
> with
>       Dynamic_Predicate => Grid'First (1) = 1 and Grid'First (2) = 1;
>
>    type Grid_Ptr is access Grid;
>
>    Data : Grid_Ptr := new Grid (1 .. 10, 1 .. 20);
> begin -- Alloc2
>    null;
> end Alloc2;
>
> which results in
>
> alloc2.adb:7:23: error: invalid use of subtype mark in expression or call
>
> Line 7 is the declaration of Data.
>
> -- 
> Jeff Carter
> "I like it when the support group complains that they have
> insufficient data on mean time to repair bugs in Ada software."
> Robert I. Eachus
> 91
> 


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

* Re: GNAT Error?
  2024-02-17  6:04     ` Randy Brukardt
@ 2024-02-17  6:11       ` Jeffrey R.Carter
  2024-02-18  9:48         ` Simon Wright
  0 siblings, 1 reply; 11+ messages in thread
From: Jeffrey R.Carter @ 2024-02-17  6:11 UTC (permalink / raw)


On 2024-02-17 07:04, Randy Brukardt wrote:
> I don't see anything wrong with that off-hand. It's probably a compiler bug
> of some sort. - Randy.

That's what I thought. I know some people have GNAT 14. I'll wait a bit to see 
if any of them report on if this is still the case before reporting it.

-- 
Jeff Carter
"Drown in a vat of whiskey. Death, where is thy sting?"
Never Give a Sucker an Even Break
106

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

* Re: GNAT Error?
  2024-02-17  6:11       ` Jeffrey R.Carter
@ 2024-02-18  9:48         ` Simon Wright
  2024-02-18  9:59           ` Simon Wright
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Wright @ 2024-02-18  9:48 UTC (permalink / raw)


"Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not> writes:

> On 2024-02-17 07:04, Randy Brukardt wrote:
>> I don't see anything wrong with that off-hand. It's probably a
>> compiler bug of some sort. - Randy.
>
> That's what I thought. I know some people have GNAT 14. I'll wait a
> bit to see if any of them report on if this is still the case before
> reporting it.

None of GCC 11.2.0, 12.2.0, 13.2.0, 14.0.1 report errors with
alloc2.adb.

These are all apple-darwin, but the error reported is going to be a
front-end error.

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

* Re: GNAT Error?
  2024-02-18  9:48         ` Simon Wright
@ 2024-02-18  9:59           ` Simon Wright
  2024-02-18 11:48             ` Jeffrey R.Carter
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Wright @ 2024-02-18  9:59 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

> "Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not> writes:
>
>> On 2024-02-17 07:04, Randy Brukardt wrote:
>>> I don't see anything wrong with that off-hand. It's probably a
>>> compiler bug of some sort. - Randy.
>>
>> That's what I thought. I know some people have GNAT 14. I'll wait a
>> bit to see if any of them report on if this is still the case before
>> reporting it.
>
> None of GCC 11.2.0, 12.2.0, 13.2.0, 14.0.1 report errors with
> alloc2.adb.
>
> These are all apple-darwin, but the error reported is going to be a
> front-end error.

Oh, you didn't say that -gnata is needed to provoke the error, though
it's not really a surprise.

Now, only GCC 11.2.0 doesn't have the error; so it's a regression in GCC
12.

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

* Re: GNAT Error?
  2024-02-18  9:59           ` Simon Wright
@ 2024-02-18 11:48             ` Jeffrey R.Carter
  2024-02-18 14:33               ` Simon Wright
  0 siblings, 1 reply; 11+ messages in thread
From: Jeffrey R.Carter @ 2024-02-18 11:48 UTC (permalink / raw)


On 2024-02-18 10:59, Simon Wright wrote:
> 
> Oh, you didn't say that -gnata is needed to provoke the error, though
> it's not really a surprise.
> 
> Now, only GCC 11.2.0 doesn't have the error; so it's a regression in GCC
> 12.

Sorry, I should have given my compilation options. You're right that I used 
-gnata. But I did say it was related to the Dynamic_Predicate.

As you have GNAT 14 and I don't, perhaps it would be best for you to report this.

-- 
Jeff Carter
"We'll make Rock Ridge think it's a chicken
that got caught in a tractor's nuts!"
Blazing Saddles
87

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

* Re: GNAT Error?
  2024-02-18 11:48             ` Jeffrey R.Carter
@ 2024-02-18 14:33               ` Simon Wright
  2024-03-07 14:54                 ` Simon Wright
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Wright @ 2024-02-18 14:33 UTC (permalink / raw)


"Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not> writes:

> On 2024-02-18 10:59, Simon Wright wrote:
>> Oh, you didn't say that -gnata is needed to provoke the error,
>> though
>> it's not really a surprise.
>> Now, only GCC 11.2.0 doesn't have the error; so it's a regression in
>> GCC
>> 12.
>
> Sorry, I should have given my compilation options. You're right that I
> used -gnata. But I did say it was related to the Dynamic_Predicate.
>
> As you have GNAT 14 and I don't, perhaps it would be best for you to
> report this.

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

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

* Re: GNAT Error?
  2024-02-18 14:33               ` Simon Wright
@ 2024-03-07 14:54                 ` Simon Wright
  2024-03-07 15:06                   ` Jeffrey R.Carter
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Wright @ 2024-03-07 14:54 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

> "Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not> writes:
>
>> On 2024-02-18 10:59, Simon Wright wrote:
>>> Oh, you didn't say that -gnata is needed to provoke the error,
>>> though
>>> it's not really a surprise.
>>> Now, only GCC 11.2.0 doesn't have the error; so it's a regression in
>>> GCC
>>> 12.
>>
>> Sorry, I should have given my compilation options. You're right that I
>> used -gnata. But I did say it was related to the Dynamic_Predicate.
>>
>> As you have GNAT 14 and I don't, perhaps it would be best for you to
>> report this.
>
> See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113979

And now fixed on all "active" branches! (that's 11, 12, 13 & master,
judging by the comments)

Of course, it takes a while for this to percolate through to a release.

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

* Re: GNAT Error?
  2024-03-07 14:54                 ` Simon Wright
@ 2024-03-07 15:06                   ` Jeffrey R.Carter
  0 siblings, 0 replies; 11+ messages in thread
From: Jeffrey R.Carter @ 2024-03-07 15:06 UTC (permalink / raw)


On 2024-03-07 15:54, Simon Wright wrote:
> Simon Wright <simon@pushface.org> writes:
>>
>> See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113979
> 
> And now fixed on all "active" branches! (that's 11, 12, 13 & master,
> judging by the comments)
> 
> Of course, it takes a while for this to percolate through to a release.

Cool. Thanks for reporting this.

-- 
Jeff Carter
"C's solution to this [variable-sized array parameters] has real
problems, and people who are complaining about safety definitely
have a point."
Dennis Ritchie
25

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

end of thread, other threads:[~2024-03-07 15:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-16 22:51 GNAT Error? Jeffrey R.Carter
2024-02-16 23:26 ` Niklas Holsti
2024-02-16 23:45   ` Jeffrey R.Carter
2024-02-17  6:04     ` Randy Brukardt
2024-02-17  6:11       ` Jeffrey R.Carter
2024-02-18  9:48         ` Simon Wright
2024-02-18  9:59           ` Simon Wright
2024-02-18 11:48             ` Jeffrey R.Carter
2024-02-18 14:33               ` Simon Wright
2024-03-07 14:54                 ` Simon Wright
2024-03-07 15:06                   ` Jeffrey R.Carter

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