I don’t think that casting a range of bits as some other arbitrary type “is a bug nobody sees coming”.

C++ compilers also warn you that this is likely an issue and will fail to compile if configured to do so. But it will let you do it if you really want to.

That’s why I love C++

  • sunbeam60@lemmy.one
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    10 hours ago

    Depends on the age of the codebase, the age of the compiler and the culture of the team.

    I’ve arrived into a team with 1000+ warnings, no const correctness (code had been ported from a C codebase) and nothing but C style casts. Within 6 months, we had it all cleaned up but my least favourite memory from that time was “I’ll just make this const correct; ah, right, and then this; and now I have to do this” etc etc. A right pain.

    • merc@sh.itjust.works
      link
      fedilink
      arrow-up
      2
      ·
      9 hours ago

      So, did you get it down to 0 warnings and manage to keep it there? Or did it eventually start creeping up again?

      • shane@feddit.nl
        link
        fedilink
        arrow-up
        1
        ·
        5 hours ago

        I’m not the person you’re asking but surely they just told the compiler to treat warnings as errors after that. No warnings can creep in then!