27

This came from a friend of mine who found this in a code repo at work.

Comments
  • 0
    What the actual fuck?!?! 😨
  • 3
    i always wanted to propose a suicide risk assessment method for developers from their code.
    This one earns a high score.
  • 6
    This is not even guaranteed to fail since optimizing compilers will just remove that block of code.

    Integer division by zero is undefined behaviour. Compilers will assume undefined behaviour can never happen, thus they assume the pool can never overflow, thus convincing themselves that the conditional is dead code and remove it.
  • 1
    1. Why recreate malloc?
    2. Isn't it meant to return a null pointer in that case?
  • 3
    "C++ is a highly flexible language which can allow for very efficient programmes"

    ... can .... CAN
  • 2
    No clue what this code is for
  • 1
    How old are u if IAM allowed to ask?
  • 0
  • 0
    @Zennoe Some compiler will optimize it away, or won't even compile and just cry.
  • 0
    @Zennoe Oh, sorry, miss read your Question.

    It's undefined behaviour, but I think most will halt execution.

    But its undefined behaviour so who knows?
  • 1
    @CompileNix May u want to talk while coding, because I am searching someone to talk about coding
Add Comment