jeroen.dobbelaere added a comment. I don't think that 'restrict' is a good match for this behavior. For c++, the alias_set proposal (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4150.pdf) would be a better match. You would put the read access of *p in its own universe; or even better, something like
struct X { int a; char [[alias_set(MyOwnUniverseForX_b)]] b; }; Unfortunatly, there is no implementation yet. Imho, adding a '__attribute__((invariant))' or something similar (immutable ? const_invariant ?) would be a better approach. (hmm, I like 'immutable') char test2(X *x) { const char __attribute__((immutable)) *p = (const char __attribute__((immutable))*)&(x->b); // for all i: p[i] will never be modified. return *p; } Extra precautions are probably needed to ensure that the initialization of x->b is separated from the usage of it. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D75285/new/ https://reviews.llvm.org/D75285 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits