News for hackers. Stuff that matters.
Re:A Special Kind of Hell: intmax_t in C and C++ by TwoBit on Saturday December 05, 2020 @04:47PM (#25318730)
The only type worse than 'int' is 'long'.
Re:A Special Kind of Hell: intmax_t in C and C++ by PaulDavisThe1st on Saturday December 05, 2020 @05:54PM (#25319227)
it's really a tie between "int", "long" and DWORD (though thankfully DWORD never made it into a language standard).

I would put "char" in the running now that we (thankfully) live in an increasingly UTF-8 world, but at least it's more or less universally understood to mean an 8 bit entity (even though this is not strictly true). It certainly isn't "a character".

Re:A Special Kind of Hell: intmax_t in C and C++ by mehrdadn on Sunday December 06, 2020 @03:38AM (#25322074)
long is definitely worse than int. At least you know int is never 64-bit on desktops, and it comes in handy enough for things like logarithms. long being either 32-bit or 64-bit on the same platform depending on the compiler just feels like insanity.
Re:A Special Kind of Hell: intmax_t in C and C++ by MaulingMonkey on Sunday December 06, 2020 @10:39AM (#25324171)
It's absolutely insanity. A cruel question I came up with the other day, based on it - What is the result of:

    std::is_signed<decltype(1L * 2U)>()

?
Re:A Special Kind of Hell: intmax_t in C and C++ by folmar on Sunday December 06, 2020 @02:14PM (#25325818)
Why should it be cruel? Promotions are a part of life of an integer in C.
Re:A Special Kind of Hell: intmax_t in C and C++ by MaulingMonkey on Sunday December 06, 2020 @07:35PM (#25328107)
Even programmers who are roughly aware of integral promotion rules may not have connected all the dots to realize the answer is implementation dependent.

If sizeof(long) == sizeof(unsigned int), 1L * 2U results in an unsigned int, meaning the result is "false".

If sizeof(long) > sizeof(unsigned int), 1L * 2U result in a signed long, meaning the result is "true".

Re:A Special Kind of Hell: intmax_t in C and C++ by mehrdadn on Sunday December 06, 2020 @09:16PM (#25328733)
Wow that is cruel! Somehow I just assumed int would get promoted to long regardless of their size difference. That this isn't the case almost seems like a language defect!