IssueRaiser

The post hinges on the faulty assumption that calculating the address of an lvalue "evaluates" that lvalue.

The post hinges on the faulty assumption that calculating the address of an lvalue "evaluates" that lvalue. This is not so. Any compiler that generates anything other than an add instruction (or lea or similar) is broken, for rather unsubtle reasons. Or to put it another way: dereferencing a null pointer may be undefined, but arithmetic on any pointer (including null) is well defined, and the code in question is arithmetic, not dereference. And, yet another broken blog post will make the rounds on the internet every three years and confuse even more people. It's sad.

Posted by jwatte on Apr 21, 2015, 2:51 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.7,000 issues0 comments

reliability (Network)

The post hinges on the faulty assumption that calculating the address of an lvalue "evaluates" that lvalue.

jwatteApr 21, 2015, 2:51 AM

The post hinges on the faulty assumption that calculating the address of an lvalue "evaluates" that lvalue. This is not so. Any compiler that generates anything other than an add instruction (or lea or similar) is broken, for rather unsubtle reasons. Or to put it another way: dereferencing a null pointer may be undefined, but arithmetic on any pointer (including null) is well defined, and the code in question is arithmetic, not dereference. And, yet another broken blog post will make the rounds on the internet every three years and confuse even more people. It's sad.

Comments (0)

No comments yet. Start the discussion.

Comment on this issue