This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug ada/60078] acats c761007 fails on ARM


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60078

--- Comment #8 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
(In reply to Eric Botcazou from comment #7)
> > could it be that the Finalize procedure is missing some sort of spin lock?
> 
> There are already explicit delays in the test, so very likely not.

I added the line "delay 0.01; -- <= additional delay here"

and the result was the test fails on X86_64.

If I rewrite both Finalize methods to use protected data like this
the test starts to pass again with the delays.

$ cat c761007_0.ads

with Ada.Finalization;
package C761007_0 is

  type Internal is new Ada.Finalization.Controlled
    with record
      Effect : Character;
    end record;

  procedure Finalize( I: in out Internal );

  protected Data is
    procedure Add( Effect : Character );
  private
    Side_Effect : String(1..80);  -- way bigger than needed
    Side_Effect_Finger : Natural := 0;
  end Data;

end C761007_0;


$ cat c761007_0.adb:

with TCTouch;
package body C761007_0 is

  procedure Finalize( I : in out Internal ) is
  begin
    Data.Add(I.Effect);
  end Finalize;

  protected body Data is
    procedure Add( Effect : Character ) is
      Previous_Side_Effect : Boolean := False;
    begin
      -- look to see if this character has been finalized yet
      for SEI in 1..Side_Effect_Finger loop
        Previous_Side_Effect := Previous_Side_Effect
                                or Side_Effect(Side_Effect_Finger) = Effect;
      end loop;

      delay 0.01; -- <= additional delay here

      -- if not, then tack it on to the string, and touch the character
      if not Previous_Side_Effect then
        Side_Effect_Finger := Side_Effect_Finger +1;
        Side_Effect(Side_Effect_Finger) := Effect;
        TCTouch.Touch(Effect);
      end if;

    end Add;
  end Data;

end C761007_0;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]