News for hackers. Stuff that matters.

kmm01

Re:Everything I wish I knew when learning C on Monday November 28, 2022 @01:14PM (#33777224)
The C standard defines them very differently though:

  undefined behavior
    behavior, upon use of a nonportable or erroneous program
    construct or of erroneous data, for which this International
    Standard imposes no requirements

  unspecified behavior
    use of an unspecified value, or other behavior where this
    International Standard provides two or more possibilities
    and imposes no further requirements on which is chosen in
    any instance
Implementations need not but may obviously assume that undefined behavior does not happen. Assume that however the program behaves if undefined behavior is invoked is how the compiler chose to implement that case.
Sounds disgusting, doesn't it? The average kebab is more like 4.50 where I live and even that is suspiciously cheap.
Re:Generics enabled by default in Go tip on Saturday August 21, 2021 @01:58AM (#28254601)
Because you will already have seen that precise piece of code in a thousand other contexts?
Re:Undefined behavior in C is a reading error on Thursday May 20, 2021 @12:33PM (#27223365)
I'm afraid the author themselves is misreading the definition of undefined behavior. Undefined behavior is not "behavior upon use of a nonportable or erroneous program construct". That rephrasing completely changed the meaning. Undefined behavior is, as the C standard states, "behavior [, ...,] for which the Standard imposes no requirements". The whole ", upon use of...," part is just exemplifying situations in which undefined behavior can occur. The standard will sometimes say that a certain construct results in undefined behavior but more importantly any construct for which the standard does not specify a certain behavior has (what else?) undefined behavior.