FA-9256 / Build systems / Open access
Compiler option precedence: Defaults override requested optimization · case 01
Defaults override requested optimization.
ROOT CAUSE
The implementation substitutes list(requested) + list(defaults) for list(defaults) + list(requested), so defaults override requested optimization.
VERIFIED REPAIR
Process requested options after defaults.
Unsuccessful approach: The attempted repair substitutes list(defaults). Fixture 2 still yields ['-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(requested) + list(defaults)
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[-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 / a2a752269be8da238b2bca43d37788176ca604d2a480f4eaf2d58445f36fd5c2
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)
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[-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 | ['-O0', '-g'] | ['-Ifoo', '-Ifoo', '-O2', '-g'] | Failed |
| fixture 3 | ['-O1'] | ['-O3'] | Failed |
| fixture 4 | ['-g'] | ['-g'] | Passed |
| fixture 5 | ['-Wb'] | ['-Wb'] | Passed |
| fixture 6 | ['-g'] | ['-Ifoo', '-Ibar', '-g'] | Failed |
SHA-256 / 2bda2a19435c8bd8a44debbcfb34ee0e285815da9a0603029436ed23d6318e0b
3 / The verified repair
Exit 0"""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[-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', '-O2', '-g'] | ['-Ifoo', '-Ifoo', '-O2', '-g'] | Passed |
| fixture 3 | ['-O3'] | ['-O3'] | Passed |
| fixture 4 | ['-g'] | ['-g'] | Passed |
| fixture 5 | ['-Wb'] | ['-Wb'] | Passed |
| fixture 6 | ['-Ifoo', '-Ibar', '-g'] | ['-Ifoo', '-Ibar', '-g'] | Passed |
SHA-256 / b4bb251e00777e051e560851f671826ee06cfaf8bb741bcc364a5aa6245f0297
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.448782+00:00.
Case digest / 94e0b29d7ecd08367702760cceccafad52c6b03b7395502c0f0f047e0619adf9