By: Gabriele Svelto (gabriele.svelto.delete@this.gmail.com), October 30, 2006 8:29 am
Room: Moderated Discussions
Ricardo B (ricardo.b@xxxxx.xx) on 10/30/06 wrote:
---------------------------
>Glad you did, you are correct.
I found another interesting reference in the C99 spec for the unary * operator:
"Among the invalid values for dereferencing a pointer by the unary * operator are a null pointer, an address inappropriately aligned for the type of object pointed to, and the address of an object after the end of its lifetime."
I know I may sound like a language lawyer however I've been bitten already a couple of times by strict aliasing rules when compiling with full optimizations on. At the time it took me a while to realize that GCC was doing his job and it was me who had broken the rules. C is versatile and powerful but we are used to a lot of unspecified behaviour which usually Just Works (tm) but which may break under some (unusual?) conditions.
Gabriele
---------------------------
>Glad you did, you are correct.
I found another interesting reference in the C99 spec for the unary * operator:
"Among the invalid values for dereferencing a pointer by the unary * operator are a null pointer, an address inappropriately aligned for the type of object pointed to, and the address of an object after the end of its lifetime."
I know I may sound like a language lawyer however I've been bitten already a couple of times by strict aliasing rules when compiling with full optimizations on. At the time it took me a while to realize that GCC was doing his job and it was me who had broken the rules. C is versatile and powerful but we are used to a lot of unspecified behaviour which usually Just Works (tm) but which may break under some (unusual?) conditions.
Gabriele