FAILURE MAP
← Case archive

FA-9276 / Build systems / Open access

Compiler option precedence: Mandatory flags are appended repeatedly · case 01

Mandatory flags are appended repeatedly.

Verified by executionVariant 1 · 6 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The implementation substitutes if True: for if flag not in flags:, so mandatory flags are appended repeatedly.

VERIFIED REPAIR

Append mandatory flags only when absent.

Unsuccessful approach: The attempted repair substitutes if flag in flags:. Fixture 2 still yields ['-Ifoo', '-Ifoo', '-O2'] 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[-1])
    for flag in mandatory:
        if True: 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 fixtureActualExpectedOutcome
fixture 1[][]Passed
fixture 2['-Ifoo', '-Ifoo', '-O2', '-g']['-Ifoo', '-Ifoo', '-O2', '-g']Passed
fixture 3['-O3']['-O3']Passed
fixture 4['-g', '-g']['-g']Failed
fixture 5['-Wb']['-Wb']Passed
fixture 6['-Ifoo', '-Ibar', '-g', '-g']['-Ifoo', '-Ibar', '-g']Failed

SHA-256 / 7e7968ab8c93201af0de0ca78e405039ab9f9697eb19d1138b825f886b276169

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[-1])
    for flag in mandatory:
        if flag 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 fixtureActualExpectedOutcome
fixture 1[][]Passed
fixture 2['-Ifoo', '-Ifoo', '-O2']['-Ifoo', '-Ifoo', '-O2', '-g']Failed
fixture 3['-O3']['-O3']Passed
fixture 4['-g', '-g']['-g']Failed
fixture 5['-Wb']['-Wb']Passed
fixture 6['-Ifoo', '-Ibar']['-Ifoo', '-Ibar', '-g']Failed

SHA-256 / cc2553ffc73c81e723ea3336de2356b3ba8a2eb220e11b2707d93cbe625c85ec

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 fixtureActualExpectedOutcome
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.606971+00:00.

Case digest / 00f2765f2d077b9ea455ff068953746c16cfc54fa63fb7b1d3b2e18b42103ad0