Skip to content

migrate: UCRT assert.h expands to _wassert with wide string literals; native Windows migration of assert() bails #1140

Closed

Description

@ehartford

On native Windows, with migrate of a C file that uses assert() fails: UCRT's <assert.h> expands assert(e) to (void)((!!(e)) || (_wassert(_CRT_WIDE(#e), _CRT_WIDE(__FILE__), (unsigned)(__LINE__)), 0)), i.e. a call to _wassert(const wchar_t*, const wchar_t*, unsigned) with WIDE string literals.

migrate: untranslatable function 'check_macros': bailed at kind=111 at input.c:8:71
migrate: untranslatable function 'fail_assert': bailed at kind=111 at input.c:10:25
migrate: unsupported filtered system variable '_wassert' from C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\assert.h:33:27; add an explicit binding or extend std.libc

Two gaps: (1) the migrator has no lowering for wide string literals (L"...", CXCursor StringLiteral with a wide kind); (2) std.libc models the Darwin (__assert_rtn) and glibc (__assert_fail) reporters portably (#1138) but not UCRT's _wassert. Both are needed for a Windows-host migration of any C that asserts.

The fixture test/behavior/behav_migrate_assert_macro.w (new in #1138, PR c-algorithms-phase1) is skip-on: windows until this lands; corpora migrated on macOS/Linux run on Windows already (the reporters are modeled).

Activity

  1. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25, Windows x86_64 (win10, with.exe from main c88f3ee): does not reproduce. assert from UCRT's <assert.h> migrates and the output checks:

    > type input.c
    #include <assert.h>
    int check(int x) { assert(x > 0); return x; }
    > with.exe migrate input.c -o out.w
    migrate: C:/Users/Eric/triage1140/input.c -> C:/Users/Eric/triage1140/out.w (0 gotos, 60 unsafe)
    > findstr assert out.w
            _assert(c"x > 0".ptr, c"C:/Users/Eric/triage1140/input.c".ptr, (2 as u32))
    > with.exe check out.w
    ok
    
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