Skip to content

gen-c: an un-annotated local takes its type from the initialiser (Refs #2161) - #2734

Merged
gHashTag merged 2 commits into
masterfrom
w699-cauto
Aug 27, 2026
Merged

gen-c: an un-annotated local takes its type from the initialiser (Refs #2161)#2734
gHashTag merged 2 commits into
masterfrom
w699-cauto

Conversation

@gHashTag

Copy link
Copy Markdown
Owner

The fallback for a local with no declared type was C's int. Two arms above it already special-case integer literals (u32/u64), so what the fallback actually caught was everything else — a call among them:

pub fn big() -> u64 { return 4294967296; }
pub fn plus_one() -> u64 {
    const v = big();      // int v = big();
    return v + 1;
}

C prints 1. Rust and Zig print 4294967297. The C compiles without a diagnostic, so nothing downstream can tell — a silent wrong answer, which is worse than a loud one.

Now GNU __auto_type when there is an initialiser — the same builtin the tuple-destructure paths a few hundred lines above already emit, so it costs no new portability. Without an initialiser there is nothing for it to follow and int stays.

Measured over 746 tracked specs

before after
specs whose C output changes 396
cc -fsyntax-only -std=gnu11 errors 6163 5958
specs whose generated C is clean 19 20
specs that went clean → broken 0

That last row is the one that matters at this radius. Counting only the totals would have hidden a swap — two fixed and one broken looks the same as one fixed in a sum.

Parse count 620/746 and tests 1629 passed / 6 failed are both unchanged.

The probe now agrees across backends: C prints 4294967297, same as Rust.

Refs #2161

…#2161)

The fallback for a local with no declared type was C's `int`. Two arms
above it already special-case integer literals (u32/u64), so what the
fallback actually caught was everything else -- a CALL among them:

    pub fn big() -> u64 { return 4294967296; }
    pub fn plus_one() -> u64 {
        const v = big();      // int v = big();
        return v + 1;
    }

C prints 1. Rust and Zig print 4294967297. The C compiles without a
diagnostic, so nothing downstream can tell -- a silent wrong answer,
which is worse than a loud one.

Now GNU `__auto_type` when there is an initialiser, which is the same
builtin the tuple-destructure paths a few hundred lines above already
emit, so it costs no new portability. Without an initialiser there is
nothing for it to follow and `int` stays.

Measured over 746 tracked specs, before binary vs after:

    specs whose C output changes        396
    cc -fsyntax-only -std=gnu11 errors  6163 -> 5958
    specs whose generated C is clean      19 -> 20
    specs that went clean -> broken        0

That last row is the one that matters at this radius. Parse count
620/746 and tests 1629 passed / 6 failed are both unchanged.

The probe now agrees across backends: C prints 4294967297, same as Rust.

FROZEN_HASH resealed in the same commit (M5).
@github-actions

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-08-27 19:03:31 UTC

Summary

Status Count
Total Open PRs 8
PRs with Failing Checks 7
PRs with All Checks Green 1
READY 0
FAILING 7
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=78bc6d9b03a1 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@github-actions

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@gHashTag
gHashTag merged commit 6285849 into master Aug 27, 2026
33 of 34 checks passed
@gHashTag
gHashTag deleted the w699-cauto branch August 27, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant