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++

  • Zacryon@feddit.org
    link
    fedilink
    arrow-up
    13
    ·
    9 hours ago

    I mostly see warnings when compiling source code of other projects. If you get a warning as a dev, it’s your responsibility to deal with it. But also your risk, if you don’t. I made it a habit to fix every warning in my own projects. For prototyping I might ignore them temporarily. Some types of warnings are unavoidable sometimes.

    If you want to make yourself not ignore warnings, you can compile with -Werror if using GCC/G++ to make the compiler a pedantic asshole that doesn’t compile until you fix every fucking warning. Not advisable for drafting code, but definitely if you want to ship it.

    • Valmond@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      6 hours ago

      Except when you have to cast size_t on int and vice versa (for “small” numbers). I hate that warning.