You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(c/cpp): seed preproc_else/elif as parallel reachability entries #5357
When walk_calls treats an unconditional return as ending fall-through inside a #if / #ifdef body, sibling preproc_else / preproc_elif nodes must not be skipped. Those branches are alternate build configurations, not dead code after the return.
Expected
Same-branch calls after return; stay omitted (CubeMX-style tails).
Calls inside #else / #elif remain extracted as reachable under another configuration.
Suggested approach
Reuse the C/C++ reachability seeding used for switchcase entries in #5338: when walking a preproc_if / preproc_ifdef, also seed preproc_else / preproc_elif children as parallel entry points.
Please keep landing the #else / #elif seed via #5365; #5338 stays the return/goto/case stack only. Happy to drop the verify branch once #5365 merges onto the same base.
Update: the parallel-seed fix from #5365 is now also on #5338 tip (6d53e5c7), so alternate #elif/#else calls after a return in another arm are kept under the existing multi-world-union model.
Reachability is now one per-function pass. Every #elif / #else arm is an entry whenever its #if is, at any nesting depth. #if expressions are still not evaluated.
Checked on the current tip, C and C++:
The repro above extracts a(), b() and after(), and still omits dead().
#elif chains, #ifdef / #else and nested #if inside #else behave the same way.
A return before the whole #if block still drops every arm.
Activity
github-actions commentedon Nov 20, 2026
Thanks for opening this issue, @scarsnow. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
scarsnow commentedon Nov 20, 2026
Reproduce (current
c-return-reachability/ after #5338 reachability)Actual (extracted
callsfromf()):a(),after()— missingb()Expected:
a(),b(),after()— still omitdead()Confirmed with
graphify.extracton this fixture: same-branch dead code afterreturnis correctly dropped, but the#elsecall is skipped too.fix(c/cpp): seed preproc_else/elif as parallel reachability entries
scarsnow commentedon Nov 23, 2026
Verified on current
v8tip (a3db62f) — attribution + branchesFollow-up to the repro in #5357 (comment).
Sources (who owns what)
return/goto/case/ static infinite-loop reachabilitya3db62f)preproc_else/preproc_elifas parallel entries +#5357tests27bfc28d,13722544/ originally551874alineage)What we submitted
scarsnow/c-return-reachability@95e6b3c7— only the three scarsnow commits ona3db62f(does not absorb fix(c/cpp): keep #elif/#else calls after a return in a #if branch (stacked on #5338) #5365). Schema comment claims#5338only.scarsnow/verify/a3db62f-5338-5365@13722544=a3db62f+ fix(c-cpp): skip calls in code no path can reach #5338 commits + Deepjyoti-Sarmah’s two fix(c/cpp): keep #elif/#else calls after a return in a #if branch (stacked on #5338) #5365 commits (authorship preserved).Result on the combined tip
a(),b(),after();dead()stays omitted.uv run pytest tests/test_c_return_reachability.py -q→ 34 passed (28 from fix(c-cpp): skip calls in code no path can reach #5338 + fix(c/cpp): seed preproc_else/elif as parallel reachability entries #5357 cases from fix(c/cpp): keep #elif/#else calls after a return in a #if branch (stacked on #5338) #5365).Please keep landing the
#else/#elifseed via #5365; #5338 stays the return/goto/case stack only. Happy to drop the verify branch once #5365 merges onto the same base.fix(c/cpp): seed preproc_else/elif as parallel reachability entries
fix(c/cpp): bump AST cache schema for preproc else/elif seeding
scarsnow commentedon Nov 24, 2026
Update: the parallel-seed fix from #5365 is now also on #5338 tip (
6d53e5c7), so alternate#elif/#elsecalls after areturnin another arm are kept under the existing multi-world-union model.merge(v8): resolve Graphify-Labs#5338 cache schema conflict
merge(v8): resolve Graphify-Labs#5338 cache schema conflict on top of…
scarsnow commentedon Nov 27, 2026
Status: this is fixed on the current #5338 tip (
1d49d69f, merged withv80.9.121), and #5338 is linked to close this issue.d3f512ec,c0a57311) are on the branch with authorship kept. fix(c-cpp): skip calls in code no path can reach #5338 now carries the#else/#elifseeding itself, which replaces the earlier plan to land it through fix(c/cpp): keep #elif/#else calls after a return in a #if branch (stacked on #5338) #5365.#elif/#elsearm is an entry whenever its#ifis, at any nesting depth.#ifexpressions are still not evaluated.a(),b()andafter(), and still omitsdead().#elifchains,#ifdef/#elseand nested#ifinside#elsebehave the same way.returnbefore the whole#ifblock still drops every arm.