Comments (7)
Loïc's said under https://bts.frama-c.com/view.php?id=2390 that
[in the WP] formals are not (yet) allocated in the pre-state, although they are allocated just before the first statement of the body...
This seems strange to me, as the pre-state can (of course) refer to the value of formals. And, if we accept that they are in scope in the pre-state, I don't see why we would reject terms that take their address. This is probably not very useful, but not worth rejecting either.
In the post-state, Frama-C's kernel has already taken a stance, since we add \old
around the use of formals.
from acsl.
@yakobowski I tend to agree with the fact that this is a bit strange, but at the same time, the fact that formals retain their original value in the ensures
clause is an indication that they are a bit special. It might make sense to treat them as some variant of C++ reference (i.e. whose address cannot be taken).
from acsl.
I also think it is strange to say the formals are not (yet) allocated in the pre-state because we talk about their values in the preconditions.
I tend to reject taking the address of a formal argument in the contract.
(It might of course be useful to take the address in the function body.)
Is there a meaningful usage of such an address for the caller ?
I somehow doubt it and consider it as dangerous as returning the address of a local variable.
On the other hand, it might be "necessary" in a contract to take the address
because there is a predicate that has a pointer argument
//@ predicate Positive(int* a) = *a > 0;
/*@
requires Positive(&n);
*/
int foo(int n);
Should one disallow/discourage such predicates?
from acsl.
The caller does not have access to the addresses of the formals indeed, but your example of a predicate taking a pointer as argument is interesting (even though I'd expect to see pretty few examples of that in real applications).
from acsl.
Well, we tend to create predicates taking pointers as arguments since we cannot reason on sets of locations without this mechanism.
Regarding e.g. addresses of formals in the post-state, I was going to suggest banishing them when not under a \at(_, Pre)
, but this is hard to do with predicates taking labels as arguments...
from acsl.
Virgile mentioned references. Maybe one could used references in ACSL predicates...
(My apologies, if this is a sacrilege!-)
from acsl.
Of course, it could be useful to take the address of formals, but as far I remember, specifications taking such an address can be always rewritten without taking that address. Here there is two example where in C the address of formals has to be taken, but this is not necessary in the ACSL specifications:
//@ predicate P1(int t[3]) = t[0] >= t[1] + t[2] ;
//@ requires P1( (int [3]) p ); // this cast is allowed in ACSL
void g1 (int p[/*3*/]) ; // note: p is a pointer
struct st_T1 { int tab[3]; };
//@ requires P1(st.tab);
void f1 (struct st_T1 st) {
g1( &st.tab[0] );
}
//@ predicate P2(struct st_T1 st) = P1( st.tab ) ;
//@ requires P2( st );
void g2 (struct st_T1 st) ;
struct st_T2 { int a1, a2, a3; };
//@ requires P2( (struct st_T1)(st) ) ; // this cast is allowed in ACSL
void f2 (struct st_T2 st) {
g2( *(struct st_T1 *)(&st) );
}
from acsl.
Related Issues (20)
- axiomatic blocks as namepaces HOT 3
- Nested axiomatic blocks HOT 3
- Floating point comparison HOT 6
- Release of ACSL 1.12 HOT 3
- Paragraph in the right margin HOT 2
- ACSL++ virtual logic functions
- scope of ghost local variables
- Structures, Unions and Arrays in logic HOT 2
- Considering a valid pointer and an invalid pointer, should they be `\separated()`? HOT 4
- Exact program state of Pre and Post states HOT 16
- Clarification on meaning of \valid HOT 10
- type-expr is defined twice HOT 2
- Notation for non-finite floating-point values HOT 2
- Clarification on order of arguments for termination measure HOT 1
- Support of 'L' suffix for floating-point literals of type long double, and `D` for literals of type double HOT 2
- Links between `\initialized{L}(p)` and `\valid_read{L}(p)`. HOT 2
- Proposal for meaning of `\valid`, `\valid_read` w.r.t. `\initialized` HOT 8
- Clarification about label Pre
- Unbound logic variable warning when using .. to specify array length, i.e. \valid(buckets+(0..{x})), when {x} is a global variable HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from acsl.