Skip to content

c(x86-64 SysV): a variadic function with a named long double parameter is refused (definition and calls) #1732

Description

@davidgmbb

Observed

long double g(int n, long double first, ...) { return first; }
long double call(void) { return g(1, 2.0L, 3); }
$ build/Release/ide cc -c -target x86_64-linux v.c
cc: error: v.c:1:13: C IR lowering does not yet support the parameter or return value types of function 'g'

Clang 18 (--target=x86_64-linux-gnu) accepts it. The refusal is deliberate. c_ir_signature_body_supported in src/buster/lib/compiler/frontend/c/c_gen.c rejects any wide-float fixed parameter of a variadic signature ("The canonical SysV va_start path cannot account for a fixed x87 parameter yet"), and c_parse_validate_signature in c_parse.c mirrors it. Passing long double variadically already works on SysV. Only a named one before ... is refused.

On System V a named x87 long double occupies a 16-byte slot in the overflow (stack) area, so va_start must start its overflow_arg_area after it. gp_offset/fp_offset are unaffected.

#1720 lifted the same restriction for AAPCS64 binary128, where a named binary128 uses a V register like a 16-byte vector. This issue is the x87 half.

Expected

The definition and the call compile and match Clang objects in both call directions. That includes a named long double that spills to the stack after other stack arguments.

Details

Done when

The mirror and lowering gates admit the x87 shape, the canonical and MIR va_start account for the overflow slot, and a mixed-compiler fixture (Buster caller ↔ Clang callee and back) reads variadic arguments correctly after one or two named long doubles.

Activity

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