Type conversions and if expressions

In this page, John Barnes writes:

If the conditional expression is the argument of a type conversion then effectively the conversion is considered pushed down to the dependent expressions. Thus

X := Float(if P then A else B);

is equivalent to

X := (if P then Float(A) else Float(B));

So why can't I compile the following program under GNAT 10.3.0?

procedure Main is
   P : Boolean := True;
   X : Float;
   X := Float (if P then 0.5 else 32);
end Main;
   [Ada]          main.adb
main.adb:5:35: expected a real type
main.adb:5:35: found type universal integer
gprbuild: *** compilation phase failed


  • Because you’ve found a long-standing error in the compiler! (same behaviour in GCC 12.1.0).

    John Barnes’ justification is at AARM 4.5.7(10ff).

    thanks for providing real code and the error messages!