Skip to content

emit-C: the compiler's own C is four errors from compiling — a global's proxy local zeroed as global = 0 (arrays), and a str field reset through a const receiver after a borrowing concat #1043

Closed as not planned

Description

@ehartford

After #1038's fix on the C4 branch (header follows the runtime, with_* prototypes from the With declarations, &"lit" temporaries), emit-c-test compiles the compiler's C (corpus in-unit, 70 MB) down to four cc errors, two classes:

  1. array type 'int16_t[75]' is not assignable ×2:

     bb6:
         /* StorageLive(_16); */
         __with_global_escapes__4903 = 0;
    

    escapes is pcre2's pub let escapes: [75]i16 (defs/pcre2_compile). The MIR local _16 is a global proxy (MirLower.ensure_global_local, new_local(..., is_global=1)); the C backend names the proxy by the global's C name (place_text) and emits a zero store at its StorageLive. For an array global that is invalid C; for a scalar global it would zero the global at function entry — worth checking whether the LLVM path skips the store or whether this is a live C-backend bug.

  2. read-only variable is not assignable ×2 (8 sites in total in Codegen.gen_src_intrinsic and siblings):

     int64_t Codegen_gen_src_intrinsic__50773(const Codegen* _1, int32_t _2) {
         _17 = with_str_concat_n((const with_str[]){(*_1).source_text, WITH_STR_LIT("")}, 2);
         _16 = _17;
         _17 = (with_str){0};
         (*_1).source_text = (with_str){0};
    

    self.source_text ++ "" through &self: the concat borrows its parts (with_str_concat_n, not _move_first), yet the backend resets the FIELD as if it had been moved (its copied-string aliasing bookkeeping), through the const receiver pointer. Either the reset is wrong (the field was borrowed) or the receiver must not be const — the LLVM backend's behavior for the same MIR decides which.

Both are C-backend defects independent of the corpus; the corpus's own C compiles alone (0 errors). Repro: with build :emit-c-test on wo-c4 (worktree ~/.local/with-staging/c4r), log out/command/emit-c-test.

Activity

  1. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): closing as a duplicate of #955. The compiler's C no longer reaches cc: emission stops first at a tuple map key (emit-c has no hash and equality functions for a map key of type (i32, i32)). #955 now tracks the whole lane; the two classes here (a global array proxy zeroed with global = 0, and a str field reset through a const receiver) are carried there.

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