Skip to content

c_import: translated inline bodies wrap D42 math builtins in unsafe { }, refused as "unsafe block contains no unsafe operations" (MSVC <corecrt_math.h>, 16 errors on a full SDL.h import) #1876

Closed

Description

@ehartford

Found verifying #1872 on win10 (SDL 3.4.14, use c_import("SDL3/SDL.h")). MSVC's <corecrt_math.h> declares inline float wrappers (fabsf, acosf, asinf, atanf, atan2f, ceilf, cosf, expf, floorf, fmodf, logf, log10f, powf, sinf, sqrtf, tanf) that c_import translates as return unsafe { acos((__param__X as f64)) }; since D42 those are compiler builtins and not unsafe, so every wrapper is refused. Windows-only (Darwin's math.h has no such inlines). Expected: the translator wraps a call in unsafe only when the callee's call is unsafe (one owner: the same fact Sema uses, cf. #1830). Repro: a Windows use c_import("SDL3/SDL.h") with the #1872 branch: 16 errors.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions