--- layout: fc_discuss_archives title: Message 50 from Frama-C-discuss on July 2012 ---
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Frama-c-discuss] Value Analysis and the modulo operator



Dear all,

We stumbled upon the following issue today: We have a little toy program
(see code below) that uses the modulo operator in an assertion. By looking
at the state dumps generated by Frama_C_dump_each(), value analysis should
be able to assign the value "valid" to our assertion. Instead, the value
unknown is assigned. The question is: To what extent can Value Analysis
reason about the modulo operator? What should one be aware of when using it
in ACSL annotations?

Thank you very much in advance,

Sergio A. Feo-Arenis

The program:
------------------------------------------------------------------------------
#include "builtin.h"

int x;

void f(int b, int a)
{
    if (b) x = 2*a;
    else x = 2*a+1;
}

int main()
{
    int y;
    int b = 0;

    y = Frama_C_interval(0,100);

    if (y == 27)
        b = 1;
    else
        b = 0;

    f(b, y);
    Frama_C_dump_each();
    //@ assert (y == 27) ==> ((x % 2 == 0));
    return 0;
}
------------------------------------------------------------------------------
We called frama-c with the following parameters:
frama-c-gui test.c /usr/share/frama-c/builtin.c -val -slevel 10
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gforge.inria.fr/pipermail/frama-c-discuss/attachments/20120726/7a712fcf/attachment.html>