Summation on HP 42S
|
09-29-2018, 06:15 PM
(This post was last modified: 09-29-2018 08:55 PM by Thomas Okken.)
Post: #47
|
|||
|
|||
RE: Summation on HP 42S
(09-29-2018 04:06 PM)ijabbott Wrote: Not my example, but consider this C program: That "example" tests the behavior of code on integer overflow, which is undefined in C, so both the unoptimized and the optimized versions fall into the category of Not Even Wrong. If you operate under the assumption that integer overflow should behave like the underlying CPU does, then your unoptimized version behaves like you would expect on a CPU with 32-bit signed integers, and the optimized version is wrong. Your assertion that there is no bug there doesn't make it so; if a shift left is supposed to behave like on the metal, then the optimizer needs to consider the possibility that a positive signed integer might turn negative or become zero when shifted left, and the optimizer in your example obviously doesn't do that. In practice, I assume the gcc maintainers would not consider it a bug, again, because the C standard specifically states that behavior on integer overflow is undefined. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)