Optimization I'd like to see compilers be able to make: if (strlen(s)>100) -> if (strnlen(s,101)>100)
If "s" is between 1 and 100 bytes longer than the range of size_t, is this defined as true, or is strlen() itself undefined for this case? (I don't see this case explicitly covered in C99 std, but strlen returns size_t, not ssize_t, so I would assume overflow is well defined?)
-
-
there's no way to create an object larger than the range of size_t in C, and how would you access all of it if there were? And some implementations (musl) only allow allocations in the range of ssize_t.
-
I don't think size_t is required to be the same size as a pointer. You might not be able to create such a large string yourself on the heap, but that doesn't mean it can't already exist...
- Show replies
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.