Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Every time you visit for the FIRST TIME today... [Part 1]

Name: Anonymous 2013-10-20 22:56

Post a random function that you made. May be from any project you've done or make one impromptu.

Any QUALITY is allowed. No bullying!

Name: Anonymous 2014-01-09 14:01

>>185
I think this example is ok by the standards listed in >>183. The only thing undefined (correct me if I'm wrong, I have not red da standard (because I am poor and not important enough to own a copy of it)) is the value of skdist. If this value was used for something like indexing in an array, that would be bad because it's value would be unpredictable, but it's just used in an if condition. Also, both branches of the if condition achieve the same end result, while one is more efficient than the other depending on details of the underlying machine and the meaning of skdist. So from the point of view of the caller, foo behaves the same in all cases, or at least it should write the same meaningful value to outp in all cases, despite invoking undefined behavior in its interior. From a correctness point of view, it's fine. I guess I was referring more to undefined behavior affecting correctness, although there are probably some reasonable examples there as well. Like atomic assignment. Although things like that should at least be wrapped in macros.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List