3 ms·
> You can call these tutorials "wrong" I don't know who you're quoting there, but it isn't me! I said C "does not support" it. And it doesn't! > Section 6.3.2
by chrisseaton 7y ago
> You can call these tutorials "wrong"
I don't know who you're quoting there, but it isn't me! I said C "does not support" it. And it doesn't!
> Section 6.3.2.3 of the C standard indicates it is implementation defined
Yes... and how does the implementation tells it defines it?
If you check the GCC documentation you'll find they don't commit to doing anything when you cast an integer to a pointer and then use it. They deliberately leave it undefined themselves. It could do absolutely anything. And not necessarily what you think it should based on existing code and online tutorials.
If I was reviewing your code that did this, and I asked you "how do you know that this will work as you expect", you'd have nothing to stand on to back it up! You'd just be able to say "well everyone assumes it works". That's not good engineering!
I know it's a common pattern to use. But who is supporting that it will work? Not the C language spec. Not the compiler documentation. It's not supported by anyone. Hence, "does not support it".
Make sense now?
- icedchai 7y agoNope. You can look at the ARM example I included to see how one implementation defines it. It that correct or incorrect? It's implementation defined and supported by compiler vendors. Maybe not yours. If you can't find out if it's supported for your environment, you shouldn't do it. I agree. But to claim you can't do this with C in general is silly. You clearly can.
- chrisseaton 7y agoBut this whole thread is about GCC.