`<format>`: Should we verify character arrays being null-terminated when creating `basic_format_arg`?
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.2k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
There're Preconditions specified in [format.arg]/5 for constructing a basic_format_arg:
Preconditions: If
decay_t<T>ischar_type*orconst char_type*,static_cast<const char_type*>(v)points to a NTCTS ([defns.ntcts]).
And character arrays are decayed per [format.arg]/6.9:
otherwise, if
decay_t<TD>ischar_type*orconst char_type*, initializes value withstatic_cast<const char_type*>(v);
It seems that we can check the content of the array (of known bound) in this internal factory function.
Should we verify that the array is null-terminated? Note that the checking is not O(1) but still seems cheap in formatting to me.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read stl/inc/__msvc_ranges_tuple_formatter.hpp around lines 277-293 and compare the character-array handling with the cited format.arg preconditions. Determine whether checking known-bound arrays for null termination is required, and resolve what behavior and coverage would count as complete; no test file is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100