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*

8
  • OK. If x is at the maximum value for its data and 1 is added to it then it results in some weird output (0), isn't it semantic error? Commented Jul 29, 2013 at 19:09
  • Consider an odometer in a vehicle -- it has a series of interrelated wheels with the digits 0 through 9 printed on each one. The rightmost wheel rotates the fastest; when it wraps from 9 back to zero, the wheel to its immediate left advances by one. When this wheel advances from 9 to 0, the one to its left advances, and so on. Commented Jul 29, 2013 at 19:20
  • 2
    In case anybody cares about the specific example, unsigned overflow is defined as modular arithmetic (so UINT_MAX + 1 == 0). Signed overflow is undefined. Modern compilers usually have INT_MAX + 1 == INT_MIN, but there are cases you can't count on this (e.g. for (i = 0; i <= N; ++i) { ... } where N is INT_MAX is not infinite depending on optimization; see blog.llvm.org/2011/05/what-every-c-programmer-should-know.html). Commented Mar 4, 2014 at 6:07
  • 1
    "note that some semantics cannot be determined at compile-time and must therefore must be evaluated at run-time" - I like how this has a parallel to natural languages. You can't know the meaning of some phrases without context. For example, in the phrase "He likes bananas" the meaning of "he" depends on context. Commented Dec 20, 2018 at 21:20
  • 2
    Excuse me, one question, why he said "if x is a float data type, this sentence has no meaning? Commented Jan 7, 2024 at 6:46