3 ms·
I don't see this change breaking the examples you have given. You can always modify non-const objects. What you can't do is modify const objects through a point
by pubby 7y ago
I don't see this change breaking the examples you have given. You can always modify non-const objects. What you can't do is modify const objects through a pointer to non-const.
e.g.
((char*)"fooo")[0] = 1
is broken code but
int x = 0;
int const* y = &x;
*((int*)y) = 1;
is not.
- cryptonector 7y agoThat's not what I got from the quoted paragraph. I'll have to chase the links to be sure.
- jcranmer 7y agoIn LLVM terms, it's referring to these kinds of stores: @vval = constant double 1.0, align 8 define void @foo(double *val) { store double %val, double @cval, align 8 | At the LLVM level, the "const" qualifier to pointers and other non-global values get reflected nowhere in the type system. But if you declare a const global variable, that variable gets placed in a read-only data section.
- cryptonector 7y agoGot it. Thanks!