Skip to content

build: no compiler warnings from this repo's own code (#158) - #163

Merged
trendvidia merged 3 commits into
mainfrom
own-warnings-158
Nov 7, 2026
Merged

trendvidia merged 3 commits into
mainfrom
own-warnings-158

Conversation

@bfrancojr

@bfrancojr bfrancojr commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #158.

The build no longer warns about this repo's own code. Before, a Clang build showed 31 warnings and the GCC 13 CI job 39 warning lines, all of them in src/, test/ or cmd/. None was a bug. One could have become one: unknown fields in SerializeGoOrder went through a serialize call whose failure was ignored.

Changes

  • src/pxf/go_wire.cc (its own commit): unknown fields are written straight into the coded stream with WireFormat::SerializeUnknownFields. Before, they went through a temporary string with an unchecked SerializeToString. That call fails only past 2 GiB, but a failure would have dropped the unknown fields silently. The output bytes are unchanged: the new GoParity.UnknownFieldsSerializeAfterTheKnownOnes pins them.
  • -Wmissing-field-initializers: FieldSpec's optional strings (test-only) get default member initializers. schema.cc passes Violation::detail at its four call sites, so the public Violation header is unchanged. Both compilers already skip members that have a default, such as bracket_required and annotation_form.
  • -Wunused-result: the tests assert SerializeToString and SerializeToCodedStream instead of dropping them. The two ByteSizeLong calls that only fill the size cache are cast to void.
  • -Wdangling-else (GCC): braces around two EXPECTs under a bare if.
  • -Wcomment (GCC): check_decode's usage comment no longer ends its lines with \, which continued the comment onto the next line.

Also fixed

  • ld's ignoring duplicate libraries: '../lib/libgtest.a' (5 per build): the test targets link only GTest::gtest_main, which in googletest v1.15.2 already links GTest::gtest publicly.

Evidence

  • Clean local build (Apple clang 21, Homebrew protobuf 36.2): the only compiler warning left is in googletest's own gtest-printers.h (-Wcharacter-conversion), which is third-party. The search path '/opt/homebrew/Cellar/llvm/18.1.8/lib' not found linker lines come from my shell's LDFLAGS, not the repo. 726/726 tests pass.

  • CI run 42287657025 (head 1915595), all jobs green. Warning lines per job log:

    Job Warnings Tests
    ubuntu-latest / gcc-13 0 (main ad7954c: 39) 726/726
    ubuntu-latest / clang-18 0 726/726
    macos-latest / appleclang 1, googletest's gtest-printers.h 726/726
    windows-latest / msvc 7 × C4091, vcpkg protobuf's text_format.h 720/720

    What's left is in third-party headers, outside the done-when.

bfrancojr and others added 3 commits November 6, 2026 12:21
…am (#158)

WriteMessage serialized the unknown fields into a temporary string with
UnknownFieldSet::SerializeToString and dropped its result. That call
fails only past 2 GiB, but when it fails it leaves the string empty,
so the unknown fields would vanish without a word.
WireFormat::SerializeUnknownFields writes the same bytes into the
CodedOutputStream directly: no copy, and no result to drop. The
stream is a StringOutputStream, which can't fail.

GoParity.UnknownFieldsSerializeAfterTheKnownOnes pins the bytes: a
Leaf with number = 3 and two unknown fields serializes to its input.
With Abseil's flood gone (#157), a Clang build showed 31 warnings from
our code and the GCC 13 job showed 39. None was a bug. Each is now
fixed at its source:

- -Wmissing-field-initializers: FieldSpec's optional strings get
  default member initializers, and schema.cc passes Violation::detail
  at its four call sites. GCC and Clang skip members that already have
  one, such as bracket_required and annotation_form.
- -Wunused-result: the tests assert SerializeToString and
  SerializeToCodedStream instead of dropping them, and the two
  ByteSizeLong calls that only fill the size cache are cast to void.
- -Wdangling-else (GCC): braces around two EXPECTs under a bare if.
- -Wcomment (GCC): check_decode's usage comment no longer ends lines
  with a backslash, which continued the comment onto the next line.
- ld's "ignoring duplicate libraries: libgtest.a": the test targets
  link GTest::gtest_main only, which already links GTest::gtest.

A clean local build (Apple clang 21) now warns only inside googletest's
own header. 726/726 tests pass.
@trendvidia
trendvidia merged commit a0c0ca6 into main Nov 7, 2026
11 checks passed
@trendvidia
trendvidia deleted the own-warnings-158 branch November 7, 2026 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build: 31 warnings in our own code, unmasked by #156

2 participants