comp.lang.ada
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* Re: "Equality operator appears too late"
  2018-11-10 10:36  7% "Equality operator appears too late" JLotty
  2018-11-10 13:34  5% ` joakimds
@ 2019-03-12 11:47  0% ` Simon Wright
  1 sibling, 0 replies; 7+ results
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	[relevance 0%]

* Re: "Equality operator appears too late"
  2018-11-11  6:32  0%   ` Randy Brukardt
@ 2018-11-11 20:05  0%     ` Simon Wright
  0 siblings, 0 replies; 7+ results
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	[relevance 0%]

* Re: "Equality operator appears too late"
  2018-11-10 13:34  5% ` joakimds
  2018-11-10 14:36  0%   ` JLotty
@ 2018-11-11  6:32  0%   ` Randy Brukardt
  2018-11-11 20:05  0%     ` Simon Wright
  1 sibling, 1 reply; 7+ results
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	[relevance 0%]

* Re: "Equality operator appears too late"
  2018-11-10 13:34  5% ` joakimds
@ 2018-11-10 14:36  0%   ` JLotty
  2018-11-11  6:32  0%   ` Randy Brukardt
  1 sibling, 0 replies; 7+ results
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	[relevance 0%]

* Re: "Equality operator appears too late"
  2018-11-10 10:36  7% "Equality operator appears too late" JLotty
@ 2018-11-10 13:34  5% ` joakimds
  2018-11-10 14:36  0%   ` JLotty
  2018-11-11  6:32  0%   ` Randy Brukardt
  2019-03-12 11:47  0% ` Simon Wright
  1 sibling, 2 replies; 7+ results
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	[relevance 5%]

* "Equality operator appears too late"
@ 2018-11-10 10:36  7% JLotty
  2018-11-10 13:34  5% ` joakimds
  2019-03-12 11:47  0% ` Simon Wright
  0 siblings, 2 replies; 7+ results
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	[relevance 7%]

* Re: Assignment with Adjust and Task Safety
  @ 2016-03-22 19:14  4%   ` Randy Brukardt
  0 siblings, 0 replies; 7+ results
From: Randy Brukardt @ 2016-03-22 19:14 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:ncs46a$qo2$1@gioia.aioe.org...
...
> You add a mutex, global or of a narrower scope, and take it in Adjust and 
> Finalize before doing anything else with the pointer.
>
> I don't do this in my implementation of smart pointers because I consider 
> it not worth the overhead of two protected actions for being protected 
> against concurrent access to the pointer. [*]
>
> The rationale is this. Smart pointers are unlikely shared. Normally they 
> are kept in containers that are not shared or else are protected by a 
> mutex, which eliminates the problem.

Right. And notice that this performance tradeoff and rationale applies to 
virtually every library that one could imagine. For instance, it applies to 
the entire standard Ada runtime. Unless a library advertises that it works 
with task shared variables (like Ada.Containers.Unbounded_Priority_Queues), 
one should always assume it does not work without protection. (Usually, a 
"task-safe" library just ensures that *different* variables can be operated 
on by different tasks - even that can be hard to support, as in Claw.)

For future Ada, we're looking at ways to decrease the danger from shared 
variables, especially in the context of parallel loops and the like. It is 
probably the biggest danger in Ada, given that it cannot be tested for 
(given that very specific conditions have to happen for there to be a 
failure, the vast majority of the time there is no problem) and that the 
effects of violating 9.10 can be catostrophic.

                                 Randy.





^ permalink raw reply	[relevance 4%]

Results 1-7 of 7 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-03-22 14:36     Assignment with Adjust and Task Safety Jeremiah
2016-03-22 18:50     ` Dmitry A. Kazakov
2016-03-22 19:14  4%   ` Randy Brukardt
2018-11-10 10:36  7% "Equality operator appears too late" JLotty
2018-11-10 13:34  5% ` joakimds
2018-11-10 14:36  0%   ` JLotty
2018-11-11  6:32  0%   ` Randy Brukardt
2018-11-11 20:05  0%     ` Simon Wright
2019-03-12 11:47  0% ` Simon Wright

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