• 0 Posts
  • 6 Comments
Joined 4 个月前
cake
Cake day: 2025年6月4日

help-circle


  • Don’t blame this on gcc or the library/function author - it is 100% user (i.e. programmer) error. Uninitialised memory of any type is undefined behaviour in the C and C++ abstract machine. That means optimising compilers can assume it does not exist.

    For example, the compiler could see that your ‘b’ is never initialised. Therefore, using it would be undefined behaviour. So, the optimiser can assume it is never used, and it is as if that code simply does not exist: the behaviour you saw.

    I’m not saying that is what happened, nor that it will always happen, but it is a possibility.


  • zerofk@lemmy.ziptoProgrammer Humor@programming.devVintage
    link
    fedilink
    arrow-up
    16
    ·
    edit-2
    2 个月前

    You know how some languages write left-to-right, and some rught-to-left? Endianness is that, for numbers.

    Or another analogy is dates: 2025/12/31 is big endian, 31/12/2025 is little endian. And 12/31/2025 is middle endian. Which makes no sense at all because the middle is, by definition, not an end.