Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #8069 > unrolled thread

Is Adjust allowed on assignment of to a class-wide argument?

Started byVictor Porton <porton@narod.ru>
First post2017-09-29 19:40 +0300
Last post2017-09-29 19:41 +0300
Articles 2 — 1 participant

Back to article view | Back to comp.programming


Contents

  Is Adjust allowed on assignment of to a class-wide argument? Victor Porton <porton@narod.ru> - 2017-09-29 19:40 +0300
    Re: Is Adjust allowed on assignment of to a class-wide argument? Victor Porton <porton@narod.ru> - 2017-09-29 19:41 +0300

#8069 — Is Adjust allowed on assignment of to a class-wide argument?

FromVictor Porton <porton@narod.ru>
Date2017-09-29 19:40 +0300
SubjectIs Adjust allowed on assignment of to a class-wide argument?
Message-ID<oqlt18$1iuh$1@gioia.aioe.org>
Is the following program allowed to print "Adjust"?

GCC 7.2.0 does not print "Adjust". I suspect it is because GCC optimizes 
away an allowed Adjust procedure.

Is it allowed to call Adjust? Will a compiler be conforming to the spec if 
it produces from the below source a program which prints "Adjust"?

---------------
with Ada.Finalization;
with Ada.Text_IO;

procedure Test is

  type A is new Ada.Finalization.Controlled with null record;

  type B is new A with null record;

  overriding procedure Adjust (Object: in out B) is
  begin
    Ada.Text_IO.Put_Line("Adjust");
  end;

  procedure X (Arg: A'Class) is
  begin
    null;
  end;

  Object: B;

begin
  X(Object);
end;

-- 
Victor Porton - http://portonvictor.org

[toc] | [next] | [standalone]


#8070

FromVictor Porton <porton@narod.ru>
Date2017-09-29 19:41 +0300
Message-ID<oqlt4k$1j23$1@gioia.aioe.org>
In reply to#8069
Victor Porton wrote:

> Is the following program allowed to print "Adjust"?
> 
> GCC 7.2.0 does not print "Adjust". I suspect it is because GCC optimizes
> away an allowed Adjust procedure.
> 
> Is it allowed to call Adjust? Will a compiler be conforming to the spec if
> it produces from the below source a program which prints "Adjust"?
> 
> ---------------
> with Ada.Finalization;
> with Ada.Text_IO;
> 
> procedure Test is
> 
>   type A is new Ada.Finalization.Controlled with null record;
> 
>   type B is new A with null record;
> 
>   overriding procedure Adjust (Object: in out B) is
>   begin
>     Ada.Text_IO.Put_Line("Adjust");
>   end;
> 
>   procedure X (Arg: A'Class) is
>   begin
>     null;
>   end;
> 
>   Object: B;
> 
> begin
>   X(Object);
> end;
> 

Sorry, wrong Usenet group.

-- 
Victor Porton - http://portonvictor.org

[toc] | [prev] | [standalone]


Back to top | Article view | comp.programming


csiph-web