[stmt.expand] Does the for loop that calculates N need to `void`-cast the return value of incrementing the iterator? CWG3044
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
From [stmt.expand]:
where N is the result of evaluating the expression
[] consteval { std::ptrdiff_t result = 0; for (auto i = begin; i != end; ++i, ++result); return result; // distance from begin to end }()
Do we need to do a void casting here to comply with the standard's awareness of operator,?
[] consteval {
std::ptrdiff_t result = 0;
for (auto i = begin; i != end; ++i, (void)++result);
return result; // distance from begin to end
}()
If so, is this LWG or CWG, or is this editorial (which I strongly doubt)?
Contributor guide
No contributing guide indexed for this repository
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
Start with the linked [stmt.expand] paragraph and the C++ rules for the comma operator and discarded values. Compare the proposed loop expression with the standard wording and determine whether a void cast is required and which issue category applies. Done means resolving the question and updating the draft wording if a change is warranted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, tex
- Domain
- compilers, documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100