isocpp / isocpp/CppCoreGuidelines
Enum.7 Reason text is misleading
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 45.3k
- Forks
- 5.6k
- PR merge metrics
- No merged PRs in 30d
Description
The current "Reason" for Enum.7 is currently
**Reason** The default is the easiest to read and write. int is the default integer type. int is compatible with C enums.
This feels misleading, as a quick and natural reading of it strongly implies that the default type for an enum is int, when it is not. Both clang and gcc default to unsigned int on linux, while MSVC defaults to int on x64 for enums with smallish values (see https://godbolt.org/z/fPWczEon3).
The default type is also going to change based on the actual values in the enum.
I don't believe that the more complex language in the standard about "the underlying type is an integral type that can represent all the enumerator values defined in the enumeration" is useful in this guideline, however maybe you could just say something like the following (just leave int out of the reason)?
**Reason** The default is the easiest to read and write and is compatible with C enums.
Or maybe rework this guideline entirely in the face of the potentially-confusing underlying behavior?
[edit: some grammar]
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
Search the repository for Enum.7 and the quoted Reason text, then read the linked guideline and its surrounding rationale. Update the guideline wording to avoid implying that int is always the default, and verify that the rendered documentation preserves the intended explanation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100