Optimization I'd like to see compilers be able to make: if (strlen(s)>100) -> if (strnlen(s,101)>100)
-
-
Wonder if there's code that relies on the trailing memory getting touched...
-
It's possible there is, but if so this code is broken. The compiler is free to optimize out dead loads, which is ultimately what this is (if you think of it as inlining and unrolling the strlen).
-
Cut to 2028: committee fixes this “bug” by making all string functions take volatile pointers.
-
2029: volatile pointers to volatile contents
-
static volatile functions will solve this problem
-
There is talk of constexpr volatile.
- End of conversation
New conversation -
-
-
also presumably it'll reduce segfaults in similar cases
-
I was just looking at LLVM's strlen-related optimizations and there are already a bunch, this one would be easy to add
-
Yes, should be pretty easy.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
