--- layout: fc_discuss_archives title: Message 13 from Frama-C-discuss on February 2010 ---
Le lun. 01 f?vr. 2010 16:44:52 CET, "Hollas Boris (CR/AEY1)" <Boris.Hollas at de.bosch.com> a ?crit : > >> Please, look at the document "ACSL: ANSI/ISO C Specification Language", > >> section 2.3.5 about "default contracts". > > >To complete Patrick's answer, even if f2 is not annotated, it has a > >contract (requires \true; ensures \true;), thus the schema you > >described above still holds (of course, you'll have trouble proving > >anything related to K after line (*)). > > However, I see a problem with a postcondition \true: Assume you have statements S; T in the code where S is a call of an unannotated function and T is some statement. Further, assume the verifier has shown {P} T {Q}, where P = wp(T,Q) is the weakest precondition of T wrt Q. Then, the verifier has to show that true -> P is valid, which means it has to show that P is valid. The problem I see is that the verifier will fail here. > The verifier won't necessarily fail: P itself can be true, for instance if Q speaks about variables which are assigned in T, e.g. /*@ ensures X == 0; */ void f () { f2() ; X = 0; } can be proved without any annotation on f2. Now, the verifier can be a bit smarter than that thanks to the assigns clauses. In fact, assigns are a special kind of post-condition, which says that any location not mentioned in assigns keeps the value it had before the call. For these locations, the call is thus effectively bypassed. Since assigns can be inferred from the code, if f2 is defined, no annotation may be needed to prove the post-condition of f: void f2() { Y = 2; } /*@ ensures X == 0; */ void f () { X = 0; f2(); } can be proved, but not void f2() { X = 2; } /*@ ensures X == 2; */ void f () { X = 0; f2(); } since the inferred assigns contains X, nothing is known on X in f after the call to f2, you really need to write a post-condition here. If f2 is only declared, things work in a similar way, except that the inferred assigns (visible in frama-c-gui after value analysis for instance) must be carefully checked to see if it matches the real implementation of f2 (which it won't in many cases). -- E tutto per oggi, a la prossima volta. Virgile