Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 2
    You're missing the point here. Your second line of code sum = a + b could yield undefined behavior. Commented Oct 15, 2010 at 21:12
  • if you cast sum, a and b to unsigned during your test-addition your code will work btw.. Commented Oct 15, 2010 at 21:27
  • It's undefined not because the program will crash or will behave differently. It's the exact thing the processor is doing to compute the OF flag. The standard is just trying to protect itself from non-standard cases, but it doesn't mean that you are not allowed to do this. Commented Oct 15, 2010 at 21:30
  • @Nils yeah, i wanted to do that, but I thought that four (usngined int)s will make it much more unreadable. (you know, you first read it, and try it only if you liked it). Commented Oct 15, 2010 at 21:31
  • 1
    the undefined behavior is in C, not after compiling to assembly Commented Jul 2, 2015 at 16:39