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] Frama-C: Detecting unreachable code?
- Subject: [Frama-c-discuss] Frama-C: Detecting unreachable code?
- From: boris at yakobowski.org (Boris Yakobowski)
- Date: Tue, 28 Jan 2014 14:27:38 +0100
- In-reply-to: <52E618F4.7010205@linux-france.org>
- References: <B517F47C2F6D914AA8121201F9EBEE6701C7660449A7@Mail1.FCMD.local> <52E0C26F.2000605@linux-france.org> <20140123082550.GA7256@opentech.at> <CAOH62JhyfqOmKmw5iKjx1CSifK2X6ajxZBxd--h4_nK-3OxmrA@mail.gmail.com> <52E0D85C.3060504@cea.fr> <CAOH62Jj=TOozP8yxRV7-ECSUknpVhe6_eeMwPuQGOJTYJD+5fg@mail.gmail.com> <B517F47C2F6D914AA8121201F9EBEE6701C7660449A8@Mail1.FCMD.local> <0B8A5A42-5BB3-4C9C-99A6-A07AC39A84AB@cea.fr> <B517F47C2F6D914AA8121201F9EBEE6701C7660449A9@Mail1.FCMD.local> <20140125190009.351e083d@gavalla> <B517F47C2F6D914AA8121201F9EBEE6701C7660449AC@Mail1.FCMD.local> <CAOH62JgQWFnHP0tW8H-ti7JYj48qRJzM-jJ0AqBNOAATSDYFvA@mail.gmail.com> <B517F47C2F6D914AA8121201F9EBEE6701C7660449AD@Mail1.FCMD.local> <52E618F4.7010205@linux-france.org>
Hi, On Mon, Jan 27, 2014 at 9:29 AM, David MENTRE <dmentre at linux-france.org> wrote: > Hello Dharmalingam, > > Le 25/01/2014 21:17, Dharmalingam Ganesan a ?crit : > >> For this below function, the value plugin says the >> >> [value] Values at end of function myFun: >> i ? [--..--] >> >> >> In my understanding [--, --] refers to all possible integers. But, the >> value of i for this function can never be below zero. Value's manual is misleading on this point. When querying the value of a l-value [--..--], means all possible integers *that fit within the type*. Here, on your 32 bits unsigned value, this amounts to [0..4294967295]. This is not a display artefact: for various (good) reasons, [--..--] is exactly what Value stores internally. > In fact, Value analysis knows about this fact, see below > "Frama_C_show_each_i([0..4294967295])". Exactly. When you call a primitive such as Frama_C_show_each, [--..--] is converted to the actual range. Another option is to use the "Evaluate term" contextual menu, in order to evaluate 'i+0'. > Maybe Value prints "[--..--]" because the whole range of variable "i" is > seen? Yes. > In below int.c program (with an "int" instead of "unsigned int"), the Value > analysis computes the correct range for i: > > --------------- > #include <limits.h> > > int i = 0; > > void myFun() > { > if (i == INT_MAX) { > i = 0; > } > i++; > Frama_C_show_each_i(i); > } > > void main(void) > { > while (Frama_C_nondet(0,1)) { > myFun(); > } > } > ---------------- > > $ frama-c -val `frama-c -print-share-path`/builtin.c -slevel 10 int.c > [...] > > [value] ====== VALUES COMPUTED ====== > [value] Values at end of function Frama_C_nondet: > Frama_C_entropy_source ? [--..--] > > [value] Values at end of function myFun: > i ? [1..2147483647] > [value] Values at end of function main: > Frama_C_entropy_source ? [--..--] > i ? [0..2147483647] Indeed. As [0..2147483647] does not cover the entire range for i (the negative values are missing), we do not display [--..--]. To complicate matters further, notice that your guard > if (i == INT_MAX) { > i = 0; > } is not needed to obtain those results. Since signed integer overflow is an undefined behavior, the alarm emitted by Value on the line i++ is sufficient to guarantee that i will never become negative. Without the 'if', the exact same values are inferred for i. HTH, -- Boris
- References:
- [Frama-c-discuss] Frama-C: Detecting unreachable code?
- From: dganesan at fc-md.umd.edu (Dharmalingam Ganesan)
- [Frama-c-discuss] Frama-C: Detecting unreachable code?
- From: dmentre at linux-france.org (David MENTRE)
- [Frama-c-discuss] Frama-C: Detecting unreachable code?
- From: der.herr at hofr.at (Nicholas Mc Guire)
- [Frama-c-discuss] Frama-C: Detecting unreachable code?
- From: pascal.cuoq at gmail.com (Pascal Cuoq)
- [Frama-c-discuss] Frama-C: Detecting unreachable code?
- From: nicky.williams at cea.fr (Nicky Williams)
- [Frama-c-discuss] Frama-C: Detecting unreachable code?
- From: pascal.cuoq at gmail.com (Pascal Cuoq)
- [Frama-c-discuss] Frama-C: Detecting unreachable code?
- From: dganesan at fc-md.umd.edu (Dharmalingam Ganesan)
- [Frama-c-discuss] Frama-C: Detecting unreachable code?
- From: loic.correnson at cea.fr (Loïc Correnson)
- [Frama-c-discuss] Frama-C: Detecting unreachable code?
- From: dganesan at fc-md.umd.edu (Dharmalingam Ganesan)
- [Frama-c-discuss] Frama-C: Detecting unreachable code?
- From: virgile.prevosto at m4x.org (Virgile Prevosto)
- [Frama-c-discuss] Frama-C: Detecting unreachable code?
- From: dganesan at fc-md.umd.edu (Dharmalingam Ganesan)
- [Frama-c-discuss] Frama-C: Detecting unreachable code?
- From: pascal.cuoq at gmail.com (Pascal Cuoq)
- [Frama-c-discuss] Frama-C: Detecting unreachable code?
- From: dganesan at fc-md.umd.edu (Dharmalingam Ganesan)
- [Frama-c-discuss] Frama-C: Detecting unreachable code?
- From: dmentre at linux-france.org (David MENTRE)
- [Frama-c-discuss] Frama-C: Detecting unreachable code?
- Prev by Date: [Frama-c-discuss] two-dimensional array requires clause
- Next by Date: [Frama-c-discuss] A significant case study using Frama-C
- Previous by thread: [Frama-c-discuss] Frama-C: Detecting unreachable code?
- Next by thread: [Frama-c-discuss] [PROVENANCE INTERNET] Re: Frama-C: Detecting unreachable code?
- Index(es):