WP plugin: Alt-Ergo Syntax Error

150 Views Asked by At

For the below C function, I'm getting syntax errors from Alt-Ergo for the latest version of Frama-c.

frama-c -wp -wp-rte -lib-entry  RoundNearestFive.c   -wp-out temp -wp-model="nat, real"

I'm not sure what is wrong in this generated line:

 ...
      let r_0 = dat_0 / 5.0e0 : real in   /* syntax error here */
    ...

C function under analysis

typedef unsigned short int uint16;


/*@
  @ requires 0<=dat<= 300;
*/
uint16 RoundNearestFive(float dat)
{
    uint16 result= 0;
    float fra = 0;

    result = (uint16)(dat/5);

    fra = dat - (float)result*5; // fractional part of the input

    if (fra < 2.5)
        result = (uint16) (dat-fra);
    else
        result = (uint16) (dat+(5-fra));

        return result;
}
2

There are 2 best solutions below

1
On

The WP user manual explicitly states that versions of Alt-Ergo prior to 0.95 are not supported (see page 21).

2
On

I tried Alt-Ergo (version 0.95.2 and trunk) on the formula below and I got no syntax error. Are you using an old version of Alt-Ergo ? Or maybe the syntax error is elsewhere.

--

logic dat_0 : real

goal g: let r_0 = dat_0 / 5.0e0 : real in (* syntax error here *) false