Re:We used C++20 to eliminate a class of runtime bugs
by jmgao on Friday January 14, 2022 @06:07PM
(#29941764)
A strlen of a compile-time constant, which will certainly get turned into a constant by the compiler. It does not get the length of the input string.
Re:We used C++20 to eliminate a class of runtime bugs
by jjnoakes on Saturday January 15, 2022 @12:02PM
(#29947999)
Why wouldn't the string_view constructor be inlined and get the same treatment?
Re:We used C++20 to eliminate a class of runtime bugs
by pjmlp on Saturday January 15, 2022 @02:37AM
(#29944502)
Certainly isn't a fact unless proven by examining the generated machine code.
Re:We used C++20 to eliminate a class of runtime bugs
by jmgao on Saturday January 15, 2022 @04:29AM
(#29945091)
This is a worthless statement. Do you examine all of your generated machine code to ensure that it generates correct code? Any compiler that you cannot trust to inline 3 for strlen("foo") is not one you should trust to compile anything, let alone modern C++.
Re:We used C++20 to eliminate a class of runtime bugs
by maccard on Saturday January 15, 2022 @11:06AM
(#29947405)
> Do you examine all of your generated machine code to ensure that it generates correct code?
(not OP). I examine the output if someone tells me it's slower, or if I care about performance. I did a very rough benchmark which says in this case they're equivalent [0], however that's not necessarily representative of the places it's called in. There's definitely a compile time overhead though [1]. On my current project there's ~20k files. On an 8 core machine (as an example), adding 150ms per file would add 7 minutes onto a clean build (before optimising the builds).
[0] https://quick-bench.com/q/LBarCDIigwpmXcwZSx-RgV2x4_4 [1] https://build-bench.com/b/OH8qf9AgEB_l-BhANV5qP_uSCys
Re:We used C++20 to eliminate a class of runtime bugs
by pjmlp on Saturday January 15, 2022 @03:48PM
(#29950093)
ISO C++ abstract machine and what a random C++ compiler generates out of it, don't require at any moment the realisation of your assertion.
So you either validate it actually takes place or believe in fairy tales.
The code it replaces also had a strlen in it.