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: tjoppen at acc.umu.se (Tomas Härdin)
- Date: Thu, 21 Nov 2019 14:48:50 +0100
- In-reply-to: <C754AA97-3290-4B27-A225-4F8529A5BDA6@galois.com>
- References: <C754AA97-3290-4B27-A225-4F8529A5BDA6@galois.com>
ons 2019-11-20 klockan 15:58 -0800 skrev Alexander Bakst: > 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); Maybe add some @asserts for the ranges of x1 and x2 here? > > if (x1 + x2 < 128) { The prover might suspect x1 + x2 might overflow here, unless you hold its hand (adding the asserts above) > //@ assert BAR: x2 < 128; > } > } /Tomas
- References:
- [Frama-c-discuss] WP and unsigned int
- From: abakst at galois.com (Alexander Bakst)
- [Frama-c-discuss] WP and unsigned int
- Prev by Date: [Frama-c-discuss] WP and unsigned int
- Next by Date: [Frama-c-discuss] WP and unsigned int
- Previous by thread: [Frama-c-discuss] WP and unsigned int
- Next by thread: [Frama-c-discuss] WP and unsigned int
- Index(es):