Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
complier problem
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Eric Sosman, post: 2476711"] Frederick Gotham wrote On 07/28/06 12:56,: `*p+ = p' exhibits undefined behavior that the two-line rewrite does not. 6.5, paragraph 2: "[...] Furthermore, the prior value shall be read only to determine the value to be stored." In `*p++ = p' there are two reads of p's value: the permitted read on the l.h.s. as part of the ++, and another on the r.h.s. (Some may think there's a third read to determine the value that * dereferences, but not so: that value is not the value of p, but the value of the subexpression p++.) To put it another way: Why in the two-line rewrite did you choose to put the assignment first and the increment second? You could just as well have written ++p; *p = p; or (abusing C's syntax to emphasize the U.B.) ++... *p = p; ...p; [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
complier problem
Top