fix(BACKEND-TENSTORRENT-QWEN35): guard the empty-vector fwrite GCC 15 flags under -Werror=nonnull - #2022
Open
joral wants to merge 1 commit into
Open
fix(BACKEND-TENSTORRENT-QWEN35): guard the empty-vector fwrite GCC 15 flags under -Werror=nonnull#2022joral wants to merge 1 commit into
joral wants to merge 1 commit into
Conversation
… flags under -Werror=nonnull Issue mudler#2021. A fresh CPU build of main fails under GCC 15.2.0: 'error: argument 1 null where non-null expected [-Werror=nonnull]' at the Tenstorrent DebugDeviceReadbackF32 dump path's fwrite call. vec (std::vector<float>) may be empty, in which case data() may return nullptr, and fwrite's first parameter is declared nonnull -- a size-0 fwrite on a null pointer is well-defined by the C standard, but the nonnull attribute makes the call itself UB by the letter of the standard, which GCC 15 now flags statically regardless of the runtime size. Guards the write on !vec.empty(), mirroring the pattern the raw-bytes write three lines above already uses for its own file handle. Debug- only code path (gated behind the call == 0 / qdir dump condition), so there is no behavior to preserve beyond skipping a write with nothing to write, which was already true logically and is now provable to the compiler too. Verified with a single-file targeted rebuild after reverting the object file: compiles clean under the same toolchain that reproduced the error. FOLLOWING_AGENTS_PROTOCOL Following-Agents-Protocol: true AI-Assisted: true Assisted-by: AGENT:claude-sonnet-5 [claude-code]
Collaborator
|
@mudler This is good to merge. The one-line runtime guard is the correct portable fix for GCC 15 treating a zero-count |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A fresh CPU build of
mainfails under GCC 15.2.0 with-Werror=nonnull:vec(std::vector<float>, from the TenstorrentDebugDeviceReadbackF32debug-dump path added in #1715) may be empty, in which case
data()mayreturn
nullptr;fwrite's first parameter is declarednonnull. A size-0fwriteon a null pointer is well-defined by the C standard, but theattribute makes the call itself UB by the letter of the standard, which GCC
15 now flags statically regardless of the runtime size.
Guards the write on
!vec.empty(), mirroring the pattern the raw-bytes writethree lines above already uses for its own file handle. Debug-only code path
(gated behind the
call == 0/qdirdump condition), so there is nobehavior to preserve beyond skipping a write with nothing to write — already
true logically, now provable to the compiler.
Verified with a single-file targeted rebuild (object file removed, rebuilt
alone) on the same toolchain that reproduced the error: compiles clean.
Found while building
mainfresh for an unrelated row (#1934); filed andfixed in flow as #2021 since it blocks every downstream CPU build regardless
of what else changed.
FOLLOWING_AGENTS_PROTOCOL
Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: AGENT:claude-sonnet-5 [claude-code]