Hi, On Thu, 14 Jul 2011, Mikael Morin wrote:
> Couldn't we simulate the desired behaviour with more than one decl, one of > them const qualified? Like so: > > void > sub (int *restrict non_aliasing_var) > { > *non_aliasing_var = 5; > { > const int *non_aliasing_var_tmp = non_aliasing_var; > some_function (); > if (*non_aliasing_var_tmp != 5) > foobar_(); > } > } Nope, const qualification is mostly ignored by the middle end. The reason is that const-ness implies only not changing the pointed-to memory _via this very pointer_. It doesn't mean the pointed-to memory isn't reachable via other means (e.g. other pointers or direct access to global memory) that could be used to change it. restrict gives you some of that, but still doesn't rule out reachability via global memory. We need something like "this pointer points to memory that isn't reachable via other mean including global memory". non-global mostly is that but requires some adjustments to escaping at function exit (otherwise many stores into it will be dead). Ciao, Michael.