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] Value analysis and MIN macro
- Subject: [Frama-c-discuss] Value analysis and MIN macro
- From: dmentre at linux-france.org (David MENTRE)
- Date: Thu, 15 Oct 2015 15:31:45 +0200
- In-reply-to: <E453609450422C4F8EB7A1BA1806686010070FFD@INF31BRUZ--WM15.DR-RES.INTRADEF.GOUV.FR>
- References: <E453609450422C4F8EB7A1BA1806686010070EE0@INF31BRUZ--WM15.DR-RES.INTRADEF.GOUV.FR> <E453609450422C4F8EB7A1BA1806686010070FFD@INF31BRUZ--WM15.DR-RES.INTRADEF.GOUV.FR>
Hello, Le 15/10/2015 09:16, GERARD Benoit a écrit : > My question is the following : is this problem potentially solvable (by > frama-c developers or may be using ACSL) Interesting issue! :-) I tried various approaches but the only one that worked for me was to put an assert that "bound <= 10" in test2() (see attached code) and then use wp to prove it (easy for Alt-Ergo in 21ms): frama-c-gui -val min-example.c -then -wp > or should people take the habit > of using an intermediate variable to perform computations before using > it in the macro (which option may ease the code review and avoid some > errors anyway)? But it is true that using an intermediate variable helps Value: no need of additional annotation and use of WP. So if you have the ability to guide people to use this style, I would go for it. Best regards, david -------------- next part -------------- #include "__fc_builtin.h" #define MIN(a,b) (((a)<(b))?(a):(b)) void test1() { char tab[10]; int i, a = Frama_C_interval(0,1000), b = 10; int bound = MIN(a,b); for ( i = 0 ; i < bound ; i ++ ) tab[i] = i; } void test2() { char tab[10]; int i, a = Frama_C_interval(0,1000), b = 10; int bound = MIN(a & 0xFF,b); //@ assert bound <= 10; for ( i = 0 ; i < bound ; i ++ ) tab[i] = i; } void test3() { char tab[10]; int i, a = Frama_C_interval(0,1000), b = 10; int atemp = a & 0xFF; int bound = MIN(atemp,b); for ( i = 0 ; i < bound ; i ++ ) tab[i] = i; } int main() { test1(); test2(); test3(); return 0; }
- Follow-Ups:
- [Frama-c-discuss] Value analysis and MIN macro
- From: Dillon.Pariente at dassault-aviation.com (Pariente Dillon)
- [Frama-c-discuss] Value analysis and MIN macro
- References:
- [Frama-c-discuss] Value analysis and MIN macro
- From: benoit.gerard at intradef.gouv.fr (GERARD Benoit)
- [Frama-c-discuss] Value analysis and MIN macro
- Prev by Date: [Frama-c-discuss] Value analysis and MIN macro
- Next by Date: [Frama-c-discuss] Value analysis and MIN macro
- Previous by thread: [Frama-c-discuss] Value analysis and MIN macro
- Next by thread: [Frama-c-discuss] Value analysis and MIN macro
- Index(es):