comp.lang.ada
 help / color / mirror / Atom feed
* Valid on QNaN generates exception, compiler bug?
@ 2002-01-31  4:04 Steve Doiel
  0 siblings, 0 replies; 7+ messages in thread
From: Steve Doiel @ 2002-01-31  4:04 UTC (permalink / raw)


  In ObjectAda 7.2 (WinNT x86) I have found that if I assign a value of
16#FFC0_0000# (QNaN) to a 32 bit floating point value using unchecked
conversion, then I try to check the value using 'VALID, I get a
Constraint_Error, numeric overflow exception.

  Is this a compiler bug?

  To paraphrase

  FUNCTION Conv IS
    NEW Ada.Unchecked_Conversion( Unsigned_32, float );

 ...
  float_value : Float;
  u32_value : Unsigned_Float;
...
  u32_value := 16#FFC0_0000#;
  float_value := Conv( u32_value );
  IF float_value'VALID THEN           -- The exception occurs on this line
    Text_Io.Put_Line( "Value is valid" );
  ELSE
    Text_Io.Put_Line( "Value is not valid" );
  END IF;

BTW: Gnat 3.13p with -gnato does not raise an exception.

Thanks,
SteveD








^ permalink raw reply	[flat|nested] 7+ messages in thread
* Valid on QNaN generates exception, compiler bug?
@ 2002-01-31  4:04 Steve Doiel
  2002-02-01 14:12 ` Stephen Leake
  0 siblings, 1 reply; 7+ messages in thread
From: Steve Doiel @ 2002-01-31  4:04 UTC (permalink / raw)


  In ObjectAda 7.2 (WinNT x86) I have found that if I assign a value of
16#FFC0_0000# (QNaN) to a 32 bit floating point value using unchecked
conversion, then I try to check the value using 'VALID, I get a
Constraint_Error, numeric overflow exception.

  Is this a compiler bug?

  To paraphrase

  FUNCTION Conv IS
    NEW Ada.Unchecked_Conversion( Unsigned_32, float );

 ...
  float_value : Float;
  u32_value : Unsigned_Float;
...
  u32_value := 16#FFC0_0000#;
  float_value := Conv( u32_value );
  IF float_value'VALID THEN           -- The exception occurs on this line
    Text_Io.Put_Line( "Value is valid" );
  ELSE
    Text_Io.Put_Line( "Value is not valid" );
  END IF;

BTW: Gnat 3.13p with -gnato does not raise an exception.

Thanks,
SteveD






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

end of thread, other threads:[~2002-02-01 22:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-31  4:04 Valid on QNaN generates exception, compiler bug? Steve Doiel
  -- strict thread matches above, loose matches on Subject: below --
2002-01-31  4:04 Steve Doiel
2002-02-01 14:12 ` Stephen Leake
2002-02-01 14:51   ` Steve Doiel
2002-02-01 21:11     ` Robert Dewar
2002-02-01 22:13       ` Steve Doiel
2002-02-01 16:16   ` Jeffrey Carter

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