Skip to content

GCC Compatibility

Derek Snider edited this page Jul 23, 2026 · 2 revisions

GCC Compatibility

madc aims for broad compatibility with real-world C code. The primary benchmark is the GCC torture test suite (gcc.c-torture/execute) — 1685 C programs designed to stress-test compilers — run under --std=c17.

Current status (v0.38.0)

1614 of 1685 pass — with zero standard-C failures outstanding.

  • 1614 pass (95.8% of the full suite; 99.4% of the 1624 in-scope tests)
  • 10 fail — every one a GNU extension, not standard C (see below)
  • 61 formally skipped — gcc-internal constructs and undefined-behavior probes, classified test-by-test in the repo (docs/parity/failset-classification.md, signed-off skip manifest)

Standard C works: every torture failure classified as standard C89–C17 has been fixed. That includes historically hard cases:

  • K&R old-style definitions and implicit int
  • VLAs — including VLA parameters with runtime bounds (char a[2][N]) evaluated at function entry, and VLA sizeof
  • Native _Complex arithmetic (__real__ / __imag__ included)
  • Struct/union pass-by-value and return (SysV ABI, mixed-class varargs)
  • Bitfields with SysV shared-window packing
  • Computed goto (labels-as-values), case ranges, statement expressions
  • Setjmp/longjmp, alloca, zero-length arrays, flexible array members
  • -0.0 preservation and long-double semantics

The 10 remaining failures — all GNU extensions

Cluster Tests
SIMD vectors wider than 16 bytes (vector_size) simd-1, simd-2, pr23135, pr92904, pr46309
__attribute__((aligned)) > 16 / misalignment probing 20010904-1, 20010904-2, misalign
Empty-union-by-value ABI corner (union + bitfields) pr23324
__sync_add_and_fetch atomic builtin pr122000

These are roadmap items (≤16-byte SIMD already works — it's in the MIR fork), not standard-compliance bugs.

What the 61 skips are

Tests that exercise gcc-internal contracts rather than the C language: inline assembly, __builtin_apply / __builtin_return_address-style frame introspection, deliberately corrupted jmp_bufs, UB probes where madc's behavior is as defensible as gcc's, and the VLA-in-struct extension (which clang also refuses to support). Each skip carries a written reason in the manifest and can be run anyway with --include-manifest-skips.

Approach: two reference compilers

madc treats both gcc and clang as canon. For any codegen, type-system, or runtime question:

  1. Reduce the failing case to a minimal C reducer
  2. Compile it with gcc -S -fverbose-asm -O0 (and clang -S -O0) and study what the reference compilers actually do
  3. Fix madc at the deepest layer that moves it toward that shape

Two additional oracles keep the backend honest: the emitted-C oracle (--emit=c11 output compiled by gcc must behave identically to madc's JIT) and clang as a scope filter (a GNU extension clang rejects is not something madc is required to support).

When the madc dialect intentionally diverges from C (e.g. 64-bit default integers outside --std=c* modes), the divergence is documented and gated behind the --std= switch — under --std=c89c23, madc behaves like a standard C compiler.

What's next?

Clone this wiki locally