Re: free()'ing restrict'ed pointers



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.
.



Relevant Pages

  • Re: Global restricted function pointer
    ... void; ... I _can_ declare a global restricted object pointer, ... the keyword restrict tells the compiler that two pointers ...
    (comp.lang.c)
  • Re: What is this noalias thing Dennis Ritchie is railing about ?
    ... And IF it were written as: void Func(int *restrict p), ... The 'restrict' keywords allow the compiler to assume that p and q do ...
    (comp.lang.c)
  • Re: Global restricted function pointer
    ... void; ... the keyword restrict tells the compiler that two pointers ... What I'd _really_ want is a global register variable, ...
    (comp.lang.c)
  • Re: free()ing restricted pointers
    ... The "restrict" keyword allows to compiler to rearrange loads and ... So if you used int* instead of void* and an assignment to *rp ... before the call to free, the compiler could move the assignment ... If we declare restricted pointer to an object, Is it true that, ...
    (comp.lang.c)
  • Re: Sequence point violation?
    ... void StrToLower ... the compiler is not obligated to evaluate the ... right side of the assignment before the left side. ... in the uncertainty principle. ...
    (comp.lang.c)