Frama-C-discuss mailing list archives

This page gathers the archives of the old Frama-C-discuss archives, that was hosted by Inria's gforge before its demise at the end of 2020. To search for mails newer than September 2020, please visit the page of the new mailing list on Renater.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Frama-c-discuss] Transformation of if-statements



Hello Boris,

2012/5/7 Boris Hollas <hollas at informatik.htw-dresden.de>:
> I noticed that the parser transforms if-else-statements such as
>
> int f6(int x, int y) {
> ?if((x == 0 && y == 0) || (x == 1 && y == 1)) return 1;
> ?else return 0;
> }
>
> into more complex if-else/goto-statements. Why is this done?

This calls for two separate answers. First, the transformation into
nested ifs is here to take into account the potential side-effects of
the expressions and ensure that they will be evaluated (or not)
according to the rules of the C standard regarding logical operators.
Second, in the general case, this transformation would include the
duplication of the original then and else branch (which can be pretty
big) into an exponential number of blocks. gotos ensure that the size
of the normalized code doesn't grow too much.

Best regards,
-- 
E tutto per oggi, a la prossima volta
Virgile