Skip to content

CWG3143 [diff.dcl] Annex C statement about type of enumerators incorrect after rebase to C23 #828

Description

@hubert-reinterpretcast

Full name of submitter (unless configured in github; will be published with the issue): Hubert Tong

Reference (section label): [diff.dcl]

Link to reflector thread (if any): N/A

Issue description:

https://wg21.link/diff.dcl#12 states that the type of enumerators in C is int. This is not true in C23 since the adoption of https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3029.htm and https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3030.htm.

Suggested resolution:

Replace "is int" with "can be int".

Activity

  1. frederick-vs-ja commented on Dec 9, 2025

    @frederick-vs-ja

    In addition to this fix, I think it's better to have a more robust example which directly relies on type difference.

  2. jensmaurer commented on Dec 9, 2025

    @jensmaurer
    Member

    @frederick-vs-ja , specific suggestions welcome.

  3. frederick-vs-ja commented on Dec 10, 2025

    @frederick-vs-ja

    Maybe the following one would be OK, as C23 also have auto type deduction added via WG14 N3007 (demo):

    void f() {
      enum e { A };
      auto x = A;
      int* p = &x; // valid C, invalid C++
    }
  4. hubert-reinterpretcast commented on Dec 11, 2025

    @hubert-reinterpretcast
    MemberAuthor

    Maybe the following one would be OK, as C23 also have auto type deduction added via WG14 N3007 (demo):

    With this example, the "How widely used" needs to change too.

  5. jensmaurer commented on Dec 11, 2025

    @jensmaurer
    Member
  6. changed the title [-][diff.dcl] Annex C statement about type of enumerators incorrect after rebase to C23[/-] [+]CWG3143 [diff.dcl] Annex C statement about type of enumerators incorrect after rebase to C23[/+] on Dec 11, 2025
  7. hubert-reinterpretcast commented on Dec 11, 2025

    @hubert-reinterpretcast
    MemberAuthor

    @jensmaurer, I think "or another integer type" is confusing (if correct under some specific reading). If the type of an enumerator is not int in C, it can have enumeration type (although enumeration types are integer types in C but not C++).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions