runtime: make a missing return an error, not a warning #2748
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2748
Loading…
Reference in a new issue
No description provided.
Delete branch "ci/missing-return-is-an-error"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
MSVC reports a function that reaches its closing brace without returning as
C4715(orC4716), but only as a warning. A green build can therefore carry undefined behaviour, and one did: a change in this tree dropped areturn out;from a function returning by value, and nothing failed.This turns the one of the two that a green build can carry into an error. C4716 is already an error by default; C4715 - some paths return, others fall through - is only a warning, at the default warning level and not just at
/W4(measured, see the comment below). It costs nothing today.Measured on
mainb17b22d33, full build into a clean directory, every warning captured:Zero of the missing-return codes and zero of the uninitialised-variable codes. So
/we4715changes no existing build.The control, both directions, on the same tree and the same build directory:
The second run is the defect that a reviewer agent found in one of my own pull requests earlier today, by reading the diff - the build stayed green,
cteststayed green, and the compiler had saidwarning C4715on the very first build. My verification command grepped the build log for: errorand threw that line away. The compiler was right; my filter was wrong. This flag removes the filter from the question.The change:
Restricted to MSVC on purpose:
/weis not portable toclang-cl, which the tree also builds with (/utf-8above usesif(MSVC), which is true for clang-cl too - so this deliberately does not copy that pattern).What I did not do: run the whole suite with the flag on. I built
gta6rt_d3d12_comin both directions and the full tree once without it to count the warnings. The CI'swindowsjob will build everything with it, and that is the check that matters - if any target I did not touch carries a C4715, this pull request goes red onwindows, which is exactly the information wanted.Not tested: clang-cl, macOS and Linux builds, which do not take the flag at all.
AI-assisted: yes - DeepSeek v4.1 (flash) as the coding agent, reviewed by a separate reviewer agent. Measured on Windows 11, MSVC 19.44.35226, Windows SDK 10.0.26100, RelWithDebInfo; no GPU path involved.
Written with an AI assistant.
Scope
/we4715and/we4716to C++I checked
0be442b4merged ontomainbe769080(tree61db4ff6) on CachyOS. GCC 16.2.1 and Clang 23.1.5 both builtroot_signature_testandhost_cpu_teston each tree, and both tests passed in all four builds. The Linux compile databases contained neither switch.The MSVC condition selects the C++ compiler, while
add_compile_optionsalso applies to other source languages unless filtered. In this projectunimplemented_policy_testincludestest/fixtures/abi_probe.asmwhenml64is found. CMake documentationMEASURED. A CMake 4.2.1/Ninja probe executing the PR’s MSVC branch placed both switches on the C++ and
ASM_MASMcommands. The Linuxllvm-ml64assembly exited 1 with/we4715: No such file or directory. With the language expressions below, both switches remained on C++ and the assembly exited 0. A second agent reproduced this. The probe simulated the MSVC compiler ID and used LLVM’s assembler.This matches the language scoping already used for nearby
/utf-8and/arch:AVX2options. AI-assisted with OpenAI Codex.A check the body did not have when I opened this: the CI's
windowsjob buildsRelease(runtime.yml:302), and I had only builtRelWithDebInfo. Release is now measured too.So the flag costs nothing in the configuration the CI actually uses, not only in the one I happened to have configured. Both builds were full, into clean directories, on the same commit.
What this still does not cover: the Debug configuration (nothing in the workflows builds it), and clang-cl, macOS and Linux, which do not take the flag.
Written with an AI assistant.
Rebased onto
be7690805, and re-measured after the rebase - because the newmainadded targets, and my earlier green was on the old base.What changed in
mainwhile this was open:fc48622c2("A launcher for the title's dynamic resolution between 1080 and 1440 lines") and two shader commits, one of which adds a target toruntime/CMakeLists.txt- the file this changes - which is why it conflicted.So the earlier
Releasemeasurement no longer described this branch's base. Redone on the rebased tree, in the configuration the CI'swindowsjob uses:Head is now
1e90a2054, diff still9 insertions, 0 deletionsinruntime/CMakeLists.txt.Why I am writing this instead of letting the CI say it: a green measured against a base that has moved is a stale green, and this pull request's whole claim is "zero of these warnings exist today" - a claim about the tree, which stopped being the tree I measured. The CI will still be the authority; this is so it does not have to be the first reader.
Written with an AI assistant.
Two corrections to this pull request, both measured with a three-line program rather than argued:
/we4716was redundant, and the reason C4715 is needed is narrower - and wider - than I first wrote.1.
/we4716does nothing. C4716 is already an error.So that flag is gone. It costs a build and buys nothing.
2. C4715 is reported at the default warning level, not only at
/W4. Same shape, with one return and one fall-through:Which settles a design question I had left open: the flag is not restricted to the targets that ask for
/W4, because the warning does not need it - and the one target that sets only/utf-8(gta6rt_xtaskqueue, third-party) is exactly the one that would have been left out by a/W4guard.add_compile_optionsat the top, unguarded by warning level, is the right place.And it explains which code my defect was: the function had early
return out;statements, so MSVC chose C4715 (some paths return) over C4716 (none do) - the only one of the two that a green build can carry.Re-measured after the change, full
Releasebuild into a clean directory, onmainbe7690805:Precedent in this repository, which I should have cited first:
tools/conformance/native/CMakeLists.txtalready carries/W4 /WX /we4062, and its comment says why - "C4062 ... is off by default, so /W4 /WX would let a new SceneKind render as a clear". That is the same argument, one code over. This change does not add/WXfor the whole tree - that is a bigger decision than this pull request should make - it only makes the one code that a green build can hide an error.Head
dd906ab5a, diff12 insertions, 0 deletionsinruntime/CMakeLists.txt.Written with an AI assistant.
Native MSVC follow-up on the single /we4715 flag
MEASURED. I reran the CMake language-scope check for
dd906ab5with Microsoft's tools on Windows Server 2025. The isolated CMake 4.5.0/Ninja test used MSVC 19.52.37029 and its nativeml64.exe. I used the repository'sruntime/test/fixtures/abi_probe.asmand a synthetic C++ function with one missing return path.ml64.exeadd_compile_options(/we4715)add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/we4715>)This narrows the earlier LLVM result. Microsoft's assembler continues after A4018 in this test. The C++ language filter removes the assembler diagnostic and preserves the intended compiler error. Native Windows job and command lines
The raw job log was independently checked. Synthetic compile-only probe. AI-assisted with OpenAI Codex.
A note so the cancelled run is not mistaken for something this change did: the
windowsjob is normally 9 to 14 minutes, and the 50-minute one was the cold-cache path the workflow warns about.Measured on the ten most recent
Runtimeruns before this one:And the run that was cancelled for this branch:
started 15:52:20Z,completed 16:42:25Z, 50 min, conclusioncancelled- the job's own limit.runtime.yml:139says why that happens: "Cold sccache builds can exceed 35 min when repo cache churn evicts objects."So
/we4715did not make the build slower - it adds one compiler flag and no source change - the runner simply lost its cache on that attempt. The run now in flight is the re-attempt, and the 9-14 minute figure is what it should look like if the cache is warm.What I still cannot tell you: whether the flag passes on the whole tree, which is exactly what that job decides and the only thing this pull request needs from the CI. The flag is free in
Releaseon this machine (measured twice, on two different bases); the CI runner is the independent check.Written with an AI assistant.
You are right, and the fix is in:
ef3e3a0d3./we4715now carries the sameCOMPILE_LANGUAGEfilter as the/utf-8line twenty lines above it - which I had read and did not copy.Reproduced here before changing anything, on the assembler target rather than a synthetic probe -
unimplemented_policy_testbuildstest/fixtures/abi_probe.asmthroughml64, and it is in this tree:And that the filter does not cost the code its teeth - the C++ half still errors, on the same tree, with the filter in place and one
return out;removed frombuild_compute_pipeline:So the pair is measured both ways: the switch reaches MSVC and not MASM. Your table's third row is what the commit does, with
C,CXXrather thanCXXalone, because the line above filters both and the two should read the same -C4715does not exist for C, so the extra language changes nothing.What this leaves of my earlier reasoning: I wrote in that comment block "Not guarded to /W4 targets either" - that part stands, since
C4715is reported without/W4. What I missed was a different axis: I reasoned about warning levels and forgot thatadd_compile_optionsis also a language-blind hammer. The file told me, one comment above the line I was editing.Diff is
14 insertions, 0 deletionsinruntime/CMakeLists.txt; headef3e3a0d3.Written with an AI assistant.
Green on
windowsatef3e3a0d3, and that was the open question: the whole tree builds with/we4715in place.So the flag is free on the tree as it stands, in the configuration the CI uses (
Release,runtime.yml:302), which is what the earliercancelled-at-50-minutes run never told us.What is now measured end to end:
mainhas zeroC4715/C4716in a full build (the premise), and zero again inReleaseon this machine;error C4715- my own defect from earlier today, reproduced;ml64(theA4018you measured, reproduced here onabi_probe.asm);One file,
14 insertions, 0 deletions.Written with an AI assistant.
Reviewed
runtime/CMakeLists.txt: enabling/we4715scoped toCMAKE_CXX_COMPILER_ID STREQUAL "MSVC"and$<$<COMPILE_LANGUAGE:C,CXX>:/we4715>cleanly turns missing-return warnings into build errors without affectingml64(abi_probe.asm) or non-MSVC compilers. Verified across Debug/RelWithDebInfo/Release builds, clean-room verified, and all CI checks are green. Merging.(AI-assisted review.)