Malcolm: Usability improvements in GCC 8
Malcolm: Usability improvements in GCC 8
Posted Mar 23, 2018 14:44 UTC (Fri) by anton (subscriber, #25547)In reply to: Malcolm: Usability improvements in GCC 8 by ncm
Parent article: Malcolm: Usability improvements in GCC 8
By the way, the compiler people say "for (int i =..." is much better, nowadays, than "for (size_t i =...", although of course "for (auto val : ..." or "std::foreach(..." is better than either.The latter two are not C, so I guess they are better in the eyes of a C++ fan.
Concerning "for (int i=...", this introduces sign-extension operations when using i for array indexing when compiling for AMD64 with -fwrapv (which is needed for a lot of production code); using long instead of int is one way to solve this if you don't expect i to wrap around.
Alternatively, this problem is also solved by using size_t (if the code is correct for size_t, which it presumably is if it started out with size_t), so suggesting that users replace size_t with int makes no sense (except if a compiler maintainer wants to justify the adversarial default of -fno-wrapv by first getting the user to pessimize his program, and then using this default to undo the pessimization).
