Skip to content

C migrator: enumeration constants typed c_uint (the enum's type) instead of int; pcre2's escapes table overflows #1774

Closed

Description

@ehartford

C11 6.7.2.2p3: "The identifiers in an enumerator list are declared as constants that have type int."

The C migrator types every enumeration constant with the enum's integer type — pcre2's enum { ESC_A = 1, ESC_G, ... } becomes pub let ESC_A: c_uint = 1 (lib/std/re/defs.w; also ucp_*, PCRE2_MATCHEDBY_*, …). C's -ESC_A is int -1; the migrated (0 - ESC_A) is c_uint 0 - 1, a checked overflow (§4.2.3). lib/std/re/pcre2_compile.w's let escapes: [75]c_short = [..., (0 - ESC_A), ...] has 26 of them; the LLVM backend's constant folder wraps them silently (issue filed beside this one), and the C backend with #1484's startup initializers panics before main in every program that carries the prelude.

Expected: enumerators are c_int (the enum type itself may stay the implementation's integer type), and the corpora are re-migrated (std.re, and any other corpus whose enumerators feed arithmetic). Blocks #1484.

Activity

  1. added 8 commits that reference this issue on Sep 28, 2026
    23074df
    fe628b7
    55d965b
    6e12473
    3edbd8a
    7342e40
    71eec23
    20a0beb
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