4 ms·
Also, not everyone uses x86(-64). In the last several years, I've used ARM, RV32 and RV64 as well as X86-64. Sounds like the original poster is painfully awar
by retrocryptid 4y ago
Also, not everyone uses x86(-64). In the last several years, I've used ARM, RV32 and RV64 as well as X86-64. Sounds like the original poster is painfully aware of platform and compiler differences, and wants to make something as general case as possible.
I mean sure, this seems like a pretty out-there corner case, but maybe they want to support the Bendix G-15 and other 1's complement machines.
- ummonk 4y agoYeah I'm not actually implementing anything but I'm curious about the common coding puzzle of "swap two numbers without a third variable" and what that's actually solvable in a non-platform specific way for signed integers given the limitations of what is actually guaranteed by the C standard.
- retrocryptid 4y agoA laudable goal, but keep in mind, neither gcc nor llvm are truly faithful to the c spec. (Though I haven't really studied C17, so maybe they've mended their ways.) I think I might say it like this: the exhibited behaviour of either gcc or llvm and the behaviour described in C11 are not proper subsets of each other. This whole exercise got me thinking if there's an architecture supported by gcc where unsigned {short, int, long, long long} and {short, int, long, long long} have different widths. (even though it's not mandated by the spec)