Timeline for std::list reimplementation
Current License: CC BY-SA 4.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 17, 2021 at 23:52 | vote | accept | Linny | ||
Jun 23, 2021 at 6:58 | comment | added | Cody Gray | He said it was an error then. It was about implicit promotions, as I described in the original comment. There's a lot of prior discussion about this question, all of which can be found with an Internet search. | |
Jun 22, 2021 at 21:48 | comment | added | Deduplicator | @CodyGray Conversely, what about the error when passing a big unsigned number to a function expecting a signed number? Also, signed arithmetic overflow is still UB, while unsigned arithmetic wraparound is well-defined. And did he say it was an error then, or that now on bigger machines it is? Also, reasons instead of appeal to authority which isn't even actually quoted is so much better to reason about. | |
Jun 22, 2021 at 21:38 | comment | added | Cody Gray | However, at this point, one has to decide whether they want to comply with the mistakes of the standard library and thereby make interoperability easier, or whether they want to fix the mistakes made by the standard library and thereby make interoperability harder. The only real solution is "safe" casts; that is, casts which thwart automatic conversion and add range checking. | |
Jun 22, 2021 at 21:37 | comment | added | Cody Gray | You're saying the same thing, @Deduplicator. Yes, it was a mistake to use unsigned integers throughout the standard library. Bjarne has admitted as much. An unsigned integer should only be used when you have a bit field, not simply because you know that the result will not be negative. This is due to a flaw in C++'s type system which allows aggressive automatic conversion between signed and unsigned integers, making it all too easy to pass a signed integer literal to a function that expects an unsigned integer, have it automatically converted, and end up unable to even detect the error. | |
Jun 21, 2021 at 16:09 | comment | added | Deduplicator | @JackAidley Is it a mistake? From a certain point of view, on modern systems, signed integers might sometimes provide an advantage. | |
Jun 21, 2021 at 9:10 | comment | added | Jack Aidley | On point 14, you may as well fix one of the mistakes in the standard library and avoid needless use of unsigned integers if you're going to implement your own. Otherwise agree. | |
Jun 21, 2021 at 7:00 | history | edited | Toby Speight | CC BY-SA 4.0 |
Spelling and grammar
|
Jun 21, 2021 at 0:19 | history | answered | Rish | CC BY-SA 4.0 |