[expr.sizeof]p2 makes an unjustified inference about the size of an array
@jensmaurer is already working on this.
Since Aug 12, 2021.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
We have:
When applied to an array, the result is the total number of bytes in the array. This implies that the size of an array of n elements is n times the size of an element.
That's the intent, but it's not implied by the other rules we specify, and starting this sentence with "This implies that" makes it sound like it's not adding a normative requirement, which it is. I think this is implied (weakly) for arrays of class types, where we say:
When applied to a class, the result is the number of bytes in an object of that class including any padding required for placing objects of that type in an array.
But even that doesn't seem to disallow, say, allocating some constant amount of extra space at the start of the array to store a bound.
Perhaps:
When applied to
an array, the result is the total number of bytes in the array. This implies that the size ofan array of n elements, the result is n times the size of an element.
? The "the result is the total number of bytes in the array" part seems redundant anyway, given p1:
The sizeof operator yields the number of bytes occupied by a non-potentially-overlapping object of the type of its operand.
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.
Assessment
This issue has not been assessed yet.