Skip to content

Conversion from integer to real

ID0000060: This issue was created automatically from Mantis Issue 60. Further discussion may take place here.


Id Project Category View Due Date Updated
ID0000060 Frama-C Kernel public 2009-04-23 2014-02-12
Reporter gmelquio Assigned To virgile Resolution fixed
Priority normal Severity major Reproducibility always
Platform - OS - OS Version -
Product Version Frama-C GIT, precise the release id Target Version - Fixed in Version Frama-C Beryllium-20090601-beta1

Description :

While the documentation says that "there are implicit coercions for numeric types: integer is itself a subtype of type real" and that cast are allowed in logic expressions, neither seem to work.

/*@ ensures 1.0 == 1; */ void f();

/*@ ensures 1.0 == (real)1; */ void g();

When running "frama-c test.c" (revision 5096), I get

File test.c, line 1, characters 19-20: Error during analysis of annotation: invalid cast between real and integer. Use conversion functions instead test.c:1: Warning: Ignoring specification of function f File test.c, line 4, characters 19-26: Error during analysis of annotation: cannot cast to logic type test.c:4: Warning: Ignoring specification of function g

The error message talks about some "conversion functions", but there are no such things in the documentation. The Jessie plugin seems to know about a \real_of_int function, but the CIL front end does not. So how does one convert an integer to a real, if neither implicit nor explicit casts work?

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information