Pointless use of restrict

Marcus Clyne maccaday@gmail.com
Mon Aug 17 11:13:00 GMT 2009


Marcus Clyne wrote:
> Hi,
>
> Am I right in saying that defining a function like
>
> func_name (my_type_t * __restrict);
>
> is pointless, because there are no other pointers that the pointer 
> could overlap with?
I was thinking about just in the parameters passed, but is the restrict 
setting also relevant to pointers that could be referenced in a circular 
fashion - e.g.

typedef struct   my_s   my_t;

struct my_s {
   my_t   *p;
};

my_t   var1, var2;

var1.p = &var2;
var2.p = &var1;

Assuming some kind of situation like this, when passing one of the 
variables above to a function, should you avoid putting a __restrict in 
the function definition because it might cause problems if you were to 
follow a pointer chain and change variables?
>
> Can anyone explain what GCC does differently for the two following 
> definitions:
>
> func1 (my_type_t * __restrict, my_type_t *__restrict);
>
> AND
>
> func2 (my_type_t *, my_type_t *);
>
> ?
>
> Thanks,
>
> Marcus.
>



More information about the Gcc-help mailing list