Namespaces
Variants
Views
Actions

Talk:c/string/byte/memset

From cppreference.com

[edit] Same as (1), except

Is there any value in mentioning something from the clause K.3.7.4.1/3? This clause seems to say that there is a case when memset_s will fill the destination array even though a runtime-constraint violation occurred. Or, is this something an expert is not likely to forget? Newatthis (talk) 07:53, 29 July 2015 (PDT)

indeed, the effects on errors were incomplete, thanks. --Cubbi (talk) 08:03, 29 July 2015 (PDT)

[edit] buffer overflow

Is there any value in emphasizing in the Notes the topic "buffer overflow?" Obviously, memset can write past the end of an array. I think that memset_s is only an incremental improvement over memset, and it too can overflow. For example, destsz >= count > actual size of destination array. Is overflow sufficiently important to mention in the Notes? Newatthis (talk) 05:15, 31 July 2015 (PDT)

this is a precondition for any function writing to a range designated by a pointer and a size. strcpy does say "The behavior is undefined if the dest array is not large enough" (not a Note since it's normative). That can be said for other such functions. Deducing and spelling out exact detail may be unnecessarily wordy ("the behavior is undefined if the size of the destination object is less than min(count,destsz) except when destsz is greater than RSIZE_MAX"?) I'd just say the same thing as strcpy. --Cubbi (talk) 07:32, 31 July 2015 (PDT)
Thanks for the feedback about brevity. I took a cue from the final sentence in 7.24.1/1. Newatthis (talk) 03:52, 12 August 2015 (PDT)