FA-9271 / Build systems / Open access
Compiler option precedence: The earliest optimization wins · case 01
The earliest optimization wins.
ROOT CAUSE
The implementation substitutes opts[0] for opts[-1], so the earliest optimization wins.
THE FAILURE
The implementation substitutes opts[0] for opts[-1], so the earliest optimization wins.
Unsuccessful approach: The attempted repair substitutes opts[len(opts)//2-1]. Fixture 2 still yields ['-Ifoo', '-Ifoo', '-O0', '-g'] instead of ['-Ifoo', '-Ifoo', '-O2', '-g'].
Case contract
Append defaults, replace optimization options by the last requested optimization, preserve repeated include options, remove explicitly disabled warnings, and append mandatory flags exactly once.
Why this case matters
An offline model of compiler option precedence, suitable for testing build and release tooling without external services.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(defaults, requested, disabled, mandatory):
flags = list(defaults) + list(requested)
opts = [x for x in flags if x.startswith('-O')]
flags = [x for x in flags if not x.startswith('-O')]
flags = [x for x in flags if x not in disabled]
if opts: flags.append(opts[0])
for flag in mandatory:
if flag not in flags: flags.append(flag)
return flags
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1', solve([], [], [], []), [])
check('fixture 2', solve(['-O0', '-Wall'], ['-O2', '-Ifoo', '-Ifoo'], ['-Wall'], ['-g']), ['-Ifoo', '-Ifoo', '-O2', '-g'])
check('fixture 3', solve(['-O1'], ['-O3'], [], []), ['-O3'])
check('fixture 4', solve(['-g'], [], [], ['-g']), ['-g'])
check('fixture 5', solve(['-Wa', '-Wb'], [], ['-Wa'], []), ['-Wb'])
check('fixture 6', solve([], ['-Ifoo', '-Ibar'], [], ['-g', '-g']), ['-Ifoo', '-Ibar', '-g'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| fixture 1 | [] | [] | Passed |
| fixture 2 | ['-Ifoo', '-Ifoo', '-O0', '-g'] | ['-Ifoo', '-Ifoo', '-O2', '-g'] | Failed |
| fixture 3 | ['-O1'] | ['-O3'] | Failed |
| fixture 4 | ['-g'] | ['-g'] | Passed |
| fixture 5 | ['-Wb'] | ['-Wb'] | Passed |
| fixture 6 | ['-Ifoo', '-Ibar', '-g'] | ['-Ifoo', '-Ibar', '-g'] | Passed |
SHA-256 / 7a25a289a42e1b0a7aad9b292cbcae308d299f4d6c7bce84911645e7178b158d
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(defaults, requested, disabled, mandatory):
flags = list(defaults) + list(requested)
opts = [x for x in flags if x.startswith('-O')]
flags = [x for x in flags if not x.startswith('-O')]
flags = [x for x in flags if x not in disabled]
if opts: flags.append(opts[len(opts)//2-1])
for flag in mandatory:
if flag not in flags: flags.append(flag)
return flags
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1', solve([], [], [], []), [])
check('fixture 2', solve(['-O0', '-Wall'], ['-O2', '-Ifoo', '-Ifoo'], ['-Wall'], ['-g']), ['-Ifoo', '-Ifoo', '-O2', '-g'])
check('fixture 3', solve(['-O1'], ['-O3'], [], []), ['-O3'])
check('fixture 4', solve(['-g'], [], [], ['-g']), ['-g'])
check('fixture 5', solve(['-Wa', '-Wb'], [], ['-Wa'], []), ['-Wb'])
check('fixture 6', solve([], ['-Ifoo', '-Ibar'], [], ['-g', '-g']), ['-Ifoo', '-Ibar', '-g'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| fixture 1 | [] | [] | Passed |
| fixture 2 | ['-Ifoo', '-Ifoo', '-O0', '-g'] | ['-Ifoo', '-Ifoo', '-O2', '-g'] | Failed |
| fixture 3 | ['-O1'] | ['-O3'] | Failed |
| fixture 4 | ['-g'] | ['-g'] | Passed |
| fixture 5 | ['-Wb'] | ['-Wb'] | Passed |
| fixture 6 | ['-Ifoo', '-Ibar', '-g'] | ['-Ifoo', '-Ibar', '-g'] | Passed |
SHA-256 / 2d59c617d6dccbdd098bf49f4611ce2fa0676088f50c1bc9985b08108e72e209
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 6 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗Verification & scope
This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:38:28.606971+00:00.
Case digest / 25e92f01849022a63f9a4ab849443240cde6393d1768a28d064670c9423f6465