Re: free()'ing restrict'ed pointers
- From: Ajay <ajay.todimala@xxxxxxxxx>
- Date: Thu, 31 Jul 2008 12:08:04 -0700 (PDT)
On Jul 31, 11:51 am, "christian.bau"
<christian....@xxxxxxxxxxxxxxxxxx> wrote:
On Jul 31, 3:37 pm, Ben Bacarisse <ben.use...@xxxxxxxxx> wrote:
void *space = malloc(1);
void *restrict rp = space;
free(space); // are we modifying *rp? -- I don't know.
The "restrict" keyword allows to compiler to rearrange loads and
stores. So if you used int* instead of void* and an assignment to *rp
before the call to free (), the compiler could move the assignment
past the call to free () with bad consequences.
Two questions for clarification:
1. If we declare restricted pointer to an object, Is it true that,
essentially all the previously declared pointers cannot be used to
access the object until the restricted goes out of scope. And if we
do, the behavior is undefined
2. So in this case can I say. pointer 'space' is a not a pointer
derived from restricted pointer 'rp'.
And therefore cannot be used to access *rp. Hence cannot be used to
free it, free(space).
Thanks,
Ajay.
.
- References:
- free()'ing restrict'ed pointers
- From: s0suk3
- Re: free()'ing restrict'ed pointers
- From: Ben Bacarisse
- Re: free()'ing restrict'ed pointers
- From: christian.bau
- free()'ing restrict'ed pointers
- Prev by Date: Re: diagnostic message
- Next by Date: Re: free()'ing restrict'ed pointers
- Previous by thread: Re: free()'ing restrict'ed pointers
- Next by thread: Re: free()'ing restrict'ed pointers
- Index(es):
Relevant Pages
|