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] WP and unsigned int


  • Subject: [Frama-c-discuss] WP and unsigned int
  • From: abakst at galois.com (Alexander Bakst)
  • Date: Wed, 20 Nov 2019 15:58:32 -0800

Hi all,

I’m having some trouble proving assertion BAR below. The culprit seems to be the shift right operation — if I replace foo >> 8 with foo, then BAR is proven. Any pointers for making progress with minimal changes?

Thanks!
Alexander

#include <stdint.h>

typedef uint32_t Xuint32;

/*@ ensures x < y ==> \result == x;
    ensures x >= y ==> \result == y;
*/
Xuint32 MAX(Xuint32 x, Xuint32 y)
{
    if (x < y) {
        return x;
    }
    return y;
}

void bar(Xuint32 input) {
    Xuint32 foo = input;

    Xuint32 x1 = MAX(foo >> 8, 0xFFFF);
    Xuint32 x2 = MAX(foo, 0xFF);

    if (x1 + x2 < 128) {
        //@ assert BAR: x2 < 128;
    }
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gforge.inria.fr/pipermail/frama-c-discuss/attachments/20191120/69e4a959/attachment.html>