4 ms·
Integer promotion rules in C are so deceptive. I don't believe there's anybody who can reason about them at code skimming speeds. It's probably the best place
by knorker 7mo ago
Integer promotion rules in C are so deceptive.
I don't believe there's anybody who can reason about them at code skimming speeds. It's probably the best place to hide underhanded code.
- zahlman 7mo agoWouldn't "underhanded code" there require some ability to control UB?
- TuxSH 7mo agoDoesn't need to be UB, you can write expressions like: "some_s8_var < some_u32_var" and people will be had. Note that is not the same as "some_s8_var < some_u8_var". -Wextra catches stuff like this, alas I know of a few people that think "-Wextra is evil" (even though annoying warnings can be selectively disabled)
- zahlman 7mo agoFair enough. Given that things like `if (uid = 0) {}` can become a privilege escalation in the right context, surely code that takes the opposite branch of what it looks like is also dangerous in the wrong hands. I still remember being expected to pass -Wpedantic (and probably also -Wextra) in university.