comp.lang.ada
 help / color / mirror / Atom feed
* "Equality operator appears too late"
@ 2018-11-10 10:36 JLotty
  2018-11-10 13:34 ` joakimds
  2019-03-12 11:47 ` Simon Wright
  0 siblings, 2 replies; 6+ messages in thread
From: JLotty @ 2018-11-10 10:36 UTC (permalink / raw)


with Ada.Containers.Synchronized_Queue_Interfaces;
with Ada.Containers.Unbounded_Priority_Queues;
procedure Min_Working_Example is

   generic
      type Data_Type is private;
      type Weight_Type is (<>);
      with function "<" (Left, Right : Weight_Type) return Boolean is <>;
   package Min_Data_Structure is
   private
      type Data_Rec is record
         Data   : Data_Type;
         Weight : Weight_Type;
      end record;
      
      function Get_Priority
        (Element : Data_Rec)
      return Weight_Type;

      function Before
        (Left, Right : Weight_Type)
      return Boolean;

      package Queue_Interface is new Ada.Containers.Synchronized_Queue_Interfaces
        (Data_Rec);

      package Edge_Queue is new Ada.Containers.Unbounded_Priority_Queues
        (Queue_Interfaces => Queue_Interface,
         Queue_Priority   => Weight_Type,
         Get_Priority     => Get_Priority,
         Before           => Before);
   end Min_Data_Structure;
   
   package body Min_Data_Structure is
      function Get_Priority
        (Element : Data_Rec)
         return Weight_Type is
        (Element.Weight);

      function Before
        (Left, Right : Weight_Type)
         return Boolean is
        (Left < Right);
   end Min_Data_Structure;
begin
   null;
end Min_Working_Example;

==================================================
When compiling the above, I get the following error:
Builder results
    min_working_example.adb
        27:7 equality operator appears too late
        27:7 instantiation error at a-cuprqu.ads:76

The error is occurring when the builder tries to elaborate the Ada.Containers.Unbounded_Priority_Queues package, where and "=" operator is defined on line 76.

I'm running the following command for build:
gprbuild -q -c -f -gnatc -u -Ptest.gpr min_working_example.adb

using version:
GPRBUILD GPL 2017 (20170515) (x86_64-pc-linux-gnu)
Copyright (C) 2004-2017, AdaCore

I don't know what to do from here.  Any help you can offer would be appreciated.


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

* Re: "Equality operator appears too late"
  2018-11-10 10:36 "Equality operator appears too late" JLotty
@ 2018-11-10 13:34 ` joakimds
  2018-11-10 14:36   ` JLotty
  2018-11-11  6:32   ` Randy Brukardt
  2019-03-12 11:47 ` Simon Wright
  1 sibling, 2 replies; 6+ messages in thread
From: joakimds @ 2018-11-10 13:34 UTC (permalink / raw)


I've tried the code with GNAT Community Edition 2018 and got the same error message. My spontaneous guess is that this is a compiler bug. The work around would be to rewrite the code not to instantiate the generic package Ada.Containers.Unbounded_Priority_Queues inside a generic compilation unit. I hope somebody else in this forum has a better idea on what to do.

Best regards,
Joakim


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

* Re: "Equality operator appears too late"
  2018-11-10 13:34 ` joakimds
@ 2018-11-10 14:36   ` JLotty
  2018-11-11  6:32   ` Randy Brukardt
  1 sibling, 0 replies; 6+ messages in thread
From: JLotty @ 2018-11-10 14:36 UTC (permalink / raw)


On Saturday, November 10, 2018 at 4:34:52 PM UTC+3, joak...@kth.se wrote:
> I've tried the code with GNAT Community Edition 2018 and got the same error message. My spontaneous guess is that this is a compiler bug. The work around would be to rewrite the code not to instantiate the generic package Ada.Containers.Unbounded_Priority_Queues inside a generic compilation unit. I hope somebody else in this forum has a better idea on what to do.
> 
> Best regards,
> Joakim

I should have included that in my original post.  If I remove the generic components and add in type definitions instead, it compiles just fine. 

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

* Re: "Equality operator appears too late"
  2018-11-10 13:34 ` joakimds
  2018-11-10 14:36   ` JLotty
@ 2018-11-11  6:32   ` Randy Brukardt
  2018-11-11 20:05     ` Simon Wright
  1 sibling, 1 reply; 6+ messages in thread
From: Randy Brukardt @ 2018-11-11  6:32 UTC (permalink / raw)


<joakimds@kth.se> wrote in message 
news:499c632b-c551-46fc-9563-86594aaa0001@googlegroups.com...
> I've tried the code with GNAT Community Edition 2018 and got
> the same error message. My spontaneous guess is that this is a
> compiler bug. The work around would be to rewrite the code not
> to instantiate the generic package
> Ada.Containers.Unbounded_Priority_Queues inside a generic
> compilation unit. I hope somebody else in this forum has a better idea
> on what to do.

Use a different compiler? :-) There rarely is a *good* solution when dealing 
with a compiler bug.

>The error is occurring when the builder tries to elaborate the
>Ada.Containers.Unbounded_Priority_Queues package, where and
>"=" operator is defined on line 76.

The language-defined specification of that package doesn't contain any "=" 
operator, so the existence of such a thing itself might be the bug. Note 
that Ada 2012 adopted rules for overriding of "=" for untagged record types 
similar to those for tagged record types (that was to allow composition to 
make sense), and thus some "=" declarations that were legal in previous Ada 
aren't legal anymore. Perhaps a recent GNAT tightened up these rules and 
caught some of their library code.

                                             Randy.




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

* Re: "Equality operator appears too late"
  2018-11-11  6:32   ` Randy Brukardt
@ 2018-11-11 20:05     ` Simon Wright
  0 siblings, 0 replies; 6+ messages in thread
From: Simon Wright @ 2018-11-11 20:05 UTC (permalink / raw)


"Randy Brukardt" <randy@rrsoftware.com> writes:

> <joakimds@kth.se> wrote in message 

>>The error is occurring when the builder tries to elaborate the
>>Ada.Containers.Unbounded_Priority_Queues package, where and
>>"=" operator is defined on line 76.
>
> The language-defined specification of that package doesn't contain any
> "=" operator, so the existence of such a thing itself might be the
> bug.

This is in the package Implementation.

The code compiles OK with GCC 6.1.0 but not with GCC >= 7 or GNAT >=
2016.


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

* Re: "Equality operator appears too late"
  2018-11-10 10:36 "Equality operator appears too late" JLotty
  2018-11-10 13:34 ` joakimds
@ 2019-03-12 11:47 ` Simon Wright
  1 sibling, 0 replies; 6+ messages in thread
From: Simon Wright @ 2019-03-12 11:47 UTC (permalink / raw)


On Saturday, 10 November 2018 10:36:31 UTC, JLotty  wrote:

>         27:7 equality operator appears too late
>         27:7 instantiation error at a-cuprqu.ads:76
> 
> The error is occurring when the builder tries to elaborate the Ada.Containers.Unbounded_Priority_Queues 
> package, where and "=" operator is defined on line 76.

Did this error get reported to AdaCore?

I spotted it in the latest AUJ, and have worked out a patch (rename the 
"=" function to Eq & replace calls to it). Not sure whether the original 
equality operator was in fact too late, which would be a compiler problem 
if it wasn’t.

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

end of thread, other threads:[~2019-03-12 11:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-10 10:36 "Equality operator appears too late" JLotty
2018-11-10 13:34 ` joakimds
2018-11-10 14:36   ` JLotty
2018-11-11  6:32   ` Randy Brukardt
2018-11-11 20:05     ` Simon Wright
2019-03-12 11:47 ` Simon Wright

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