because of the definitions of size_t and of SIZE_MAX
If you want to just say it's UB or unspecified result if it doesn't fit, that's even more awful and unusable.
-
-
Sure it's UB. In the same way as printf of >INT_MAX chars.
-
Only way you can claim it's UB is by omission of a clear statement what happens. In any case, unusably bad impl.
-
This is very different from printf >INT_MAX, since there's no conceptual upper bound on printf output length.
-
If you limit width/precision then I think SIZE_MAX * SIZE_MAX should work as an upper bound.
-
The standard doesn't limit them, though. So printf("%999999999999999999999999999999999999999999999999999999d",0)
-
My point here is that the standard is full of omissions of necessary explicit requirements or error conditions.
-
It's a willfully buggy/incomplete standard by a committee who thinks "you know what we meant!" suffices...
-
Interpreting that into something without gratuitous severe usability flaws is left to the reader. :-(
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.