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] Documentation of \valid
- Subject: [Frama-c-discuss] Documentation of \valid
- From: Claude.Marche at inria.fr (Claude Marche)
- Date: Mon, 16 Nov 2009 15:23:17 +0100
- In-reply-to: <FC0686BB6178BC43B9DC035287A11A720DBD5C08CD@SI-MBX12.de.bosch.com>
- References: <FC0686BB6178BC43B9DC035287A11A720DBD57FB8C@SI-MBX12.de.bosch.com> <A4D9A80C-4F63-4879-9B09-D22780EFCF8D@cea.fr> <FC0686BB6178BC43B9DC035287A11A720DBD57FBC9@SI-MBX12.de.bosch.com> <4AFD151D.7090600@inria.fr> <FC0686BB6178BC43B9DC035287A11A720DBD5C06AF@SI-MBX12.de.bosch.com> <4B01265D.20309@inria.fr> <FC0686BB6178BC43B9DC035287A11A720DBD5C08CD@SI-MBX12.de.bosch.com>
Thanks for the contribution. However, I disagree with some of your points. First, it has nothing todo with Jessie. Only ACSL semantics is under discussion. Next, to illustrate my point: look at ACSL doc, section 2.7 where \valid is defined. You see: ---------------- \valid applies to a set of terms of some pointer type. \valid(s) holds if and only if dereferencing any p in s is safe. In particular, \valid(\empty) holds. -------------- not very precise, I admit, but just after you have: --------------------- \offset(p) returns the offset between p and its base address \offset(p) = (char*)p - \base_addr(p) the following property holds: for any set of pointers s, \valid(s) if and only if for all p in s: \offset(p) >= 0 && \offset(p) + sizeof(*p) <= \block_length(p) ------------------------------------- This last formula should be seen as the formal def of \valid(p). It is dependent of the C type of p, via the use of sizeof(*p). This def is independant of Jessie, and it has nothing to do with the fact that jessie use a so-called typed memory model or not. Now, back to your example, let's do a little test: ------------------- #include <stdio.h> struct A { int x; int y; }; struct B { struct A a; int z; }; typedef int arr3[3]; void f(arr3 t, struct B b) { printf("sizeof(int): %ld\n",sizeof(int)); printf("sizeof(void*): %ld\n",sizeof(void*)); printf("sizeof(t): %ld\n",sizeof(t)); printf("sizeof(b): %ld\n",sizeof(b)); printf("sizeof(*t): %ld\n",sizeof(*t)); } int main() { arr3 t; struct B b; f(t,b); return 0; } ---------------- What I obtain is ---------------------------- sizeof(int): 4 sizeof(void*): 8 sizeof(t): 8 sizeof(b): 12 sizeof(*t): 4 ------------------------ As you can see, the parameter of f is a pointer (size 8, on my 64-bit computer), and *t has size 4 (sizeof int). On the other hand, parameter b has size 12 (for the three ints in that structure). Hence \valid(t) means that from t, we are given 4 valid bytes \valid(b) means that from b, we are given 12 valid bytes That's it! If you want to specify that your have an array of 3 ints from t, you need \valid(t+(0..2)) All this comes from the semantics of C itself, which interprets type "arr3" in the profile of f as "int*" only - Claude Hollas Boris (CR/AEY1) wrote: > I've added a section on types in the wiki. > > _______________________________________________ > Frama-c-discuss mailing list > Frama-c-discuss at lists.gforge.inria.fr > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/frama-c-discuss > -- Claude March? | tel: +33 1 72 92 59 69 INRIA Saclay - ?le-de-France | mobile: +33 6 33 14 57 93 Parc Orsay Universit? | fax: +33 1 74 85 42 29 4, rue Jacques Monod - B?timent N | http://www.lri.fr/~marche/ F-91893 ORSAY Cedex |
- Follow-Ups:
- [Frama-c-discuss] Documentation of \valid
- From: Boris.Hollas at de.bosch.com (Hollas Boris (CR/AEY1))
- [Frama-c-discuss] Documentation of \valid
- References:
- [Frama-c-discuss] Documentation of \valid
- From: Boris.Hollas at de.bosch.com (Hollas Boris (CR/AEY1))
- [Frama-c-discuss] Documentation of \valid
- From: Pascal.Cuoq at cea.fr (Pascal Cuoq)
- [Frama-c-discuss] Documentation of \valid
- From: Boris.Hollas at de.bosch.com (Hollas Boris (CR/AEY1))
- [Frama-c-discuss] Documentation of \valid
- From: Claude.Marche at inria.fr (Claude Marche)
- [Frama-c-discuss] Documentation of \valid
- From: Boris.Hollas at de.bosch.com (Hollas Boris (CR/AEY1))
- [Frama-c-discuss] Documentation of \valid
- From: Claude.Marche at inria.fr (Claude Marche)
- [Frama-c-discuss] Documentation of \valid
- From: Boris.Hollas at de.bosch.com (Hollas Boris (CR/AEY1))
- [Frama-c-discuss] Documentation of \valid
- Prev by Date: [Frama-c-discuss] Documentation of \valid
- Next by Date: [Frama-c-discuss] goto generated by Frama-C and not supported by Jessie
- Previous by thread: [Frama-c-discuss] Documentation of \valid
- Next by thread: [Frama-c-discuss] Documentation of \valid
- Index(es):