Remix.run Logo
Someone 2 days ago

It’s a fairly common issue with C code, so you should be scared about more than OpenBSD. As an example:

  a_long = an_int * another_int;
will do the multiplication in integers, then convert the result to long. That can produce surprising results of the multiplication overflows (I think that, technically, that would be undefined behavior, allowing the compiler to do what it wants, but most compilers will generate a multiplication instruction and let the CPU do whatever it does with int overflow (wrap around and trapping are the most popular options)

Also,

  an_int = a_long;
is valid, and will do a narrowing conversion. I don’t think compilers are required to warn about that.