From eaad9c34403f05372c1544d7ef522c847dfea0ba Mon Sep 17 00:00:00 2001 From: _ov4 Date: Thu, 22 Oct 2026 13:23:04 +0000 Subject: test(extern): check variadic promotions with va_arg Co-Authored-By: Claude Opus 5.5 --- tests/i/extern-c-variadic/notes.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 tests/i/extern-c-variadic/notes.md (limited to 'tests/i/extern-c-variadic/notes.md') diff --git a/tests/i/extern-c-variadic/notes.md b/tests/i/extern-c-variadic/notes.md new file mode 100644 index 0000000..4820ecd --- /dev/null +++ b/tests/i/extern-c-variadic/notes.md @@ -0,0 +1,7 @@ +# extern-c-variadic + +Human review: pending. Expected output was independently traced by AI, not captured from cpsc. + +Basis: compiler extension (EXTERN "C", INCLUDE_OBJ of a user object); C11 6.5.2.2p6-7 default argument promotions and 7.16.1.1 va_arg. + +Trace: the harness compiles `lib.c` with the host C compiler. sum_ints reads 5 arguments with va_arg(ap, int), so each must arrive promoted to int: unsigned char 200 gives 200, short -7 gives -7, unsigned short 65535 gives 65535 (int is wider than short), _Bool TRUE gives 1 and char 'A' gives 65. 200 - 7 + 65535 + 1 + 65 = 65794. sum_doubles reads 2 arguments with va_arg(ap, double): float 1.5 is promoted to double 1.5, and double 2.25 is passed unchanged. 1.5 + 2.25 = 3.75, printed like other C doubles as `3.750000`. -- cgit v1.3.1-4-g156e