logoalt Hacker News

maccardtoday at 6:45 PM3 repliesview on HN

Indeed.

   bool is_even(int* valPtr) {
      assert(valPtr != nullptr);
      return *valPtr % 2;
    }
Does not do what you think it does with nullptr. A major game engine [0] has a toggle to enable asserts in shipping builds, mostly for this reason

[0] https://dev.epicgames.com/documentation/en-us/unreal-engine/...


Replies

dccsillagtoday at 6:59 PM

I'm sorry, but what exactly is the problem with the code? I've been staring at it for quite a while now and still don't see what is counterintuitive about it.

show 2 replies
mhh__today at 7:42 PM

This is a very "Dr Dr it hurts when I do this" "Don't do that" one it must be said.

secondcomingtoday at 9:05 PM

Let's not vague post on HN. What's the problem with the above?