Skip to content

Fix some clang++ warnings#610

Merged
biojppm merged 4 commits into
biojppm:masterfrom
TedLyngmo:clang_warn
May 28, 2026
Merged

Fix some clang++ warnings#610
biojppm merged 4 commits into
biojppm:masterfrom
TedLyngmo:clang_warn

Conversation

@TedLyngmo
Copy link
Copy Markdown
Contributor

Compiled with -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic and fixed some low hanging fruits.

Comment thread src/c4/yml/tree.cpp Fixed
Comment thread src/c4/yml/tree.cpp Fixed
@TedLyngmo TedLyngmo force-pushed the clang_warn branch 3 times, most recently from c9db1e5 to 8a4c528 Compare May 27, 2026 05:27
Comment thread src/c4/yml/node.hpp Outdated
Copy link
Copy Markdown
Owner

@biojppm biojppm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, it is really appreciated.

First, some context: -Weverything is not actually advised by clang.

There are a couple of changeset remarks/questions above. Other than these, there are a few others:

  • the initial diff had a rather large part fixing leading underscores in some symbols; subsequently they're not here. Why the revert?
  • Also, on this same subject, I think suppressing the warning as needed with file-wide push/pop is not just lower effort, but might actually be preferable. IMO there's really low risk of having these symbols clash with any other symbol.
  • what are the final compile flags that you're looking to suppress? I think adding these to the CI is in order, but I'm a bit confused as to what the flags are based on the PR description and commit error messages.
  • related - were there no warnings coming from c4core code? I would really expect that to be the case, but there's no PR there.

Comment thread src/c4/yml/node.hpp Outdated
Comment thread src/c4/yml/node.hpp Outdated
Comment thread src/c4/yml/event_handler_tree.hpp
@TedLyngmo
Copy link
Copy Markdown
Contributor Author

TedLyngmo commented May 27, 2026

First, some context: -Weverything is not actually advised by clang. But I'm really inclined

Yes, using it means you have no control over the warnings that will be enabled. Every new version of clang++ will come with new warnings. I use it as a means to enable everything in the current version of clang++ that I have - and then remove it once I've fixed everything that popped up and looked interesting enough :) Shipping a library with -Weverything enabled is not a good idea.

There are a couple of changeset remarks/questions above. Other than these, there are a few others:

  • the initial diff had a rather large part fixing leading underscores in some symbols; subsequently they're not here. Why the revert?

I misunderstood the large impact and concentrated on just being able to compile the library clean. As it happens, CI showed that there is a lot more code that depends on those identifiers :-) I removed that commit from the set and was thinking of addressing that separately now that I have a better picture of how they are used.

  • Also, on this same subject, I think suppressing the warning as needed with file-wide push/pop is not just lower effort, but might actually be preferable. IMO there's really low risk of having these symbols clash with any other symbol.

True, but there are organizations that are sticklers when it comes to undefined behavior and they'd probably reject the library when noticing these identifiers. I have seen header guards and other reserved identifiers defined in libraries collide with the implementation's own identifiers after upgrading the toolchain. Not a nice surprise.

  • what are the final compile flags that you're looking to suppress? I think adding these to the CI is in order, but I'm a bit confused as to what the flags are based on the PR description and commit error messages.

I wasn't thinking of suppressing any. Possibly adding an explicit set of warnings after having fixed those specific issues.

  • related - were there no warnings coming from c4core code? I would really expect that to be the case, but there's no PR there.

Oh, there were tons. Since it's in a submodule, I left those untouched. It'd probably be a good idea to go through those separately.

@biojppm
Copy link
Copy Markdown
Owner

biojppm commented May 27, 2026

what are the final compile flags that you're looking to suppress? I think adding these to the CI is in order, but I'm a bit confused as to what the flags are based on the PR description and commit error messages.

I wasn't thinking of suppressing any. Possibly adding an explicit set of warnings after having fixed those specific issues.

My bad -- I meant fix instead of suppress. The question still stands. What are those warnings? The PR description says one thing but individual commits show another.

Comment thread src/c4/yml/parse_engine.def.hpp Outdated
@TedLyngmo
Copy link
Copy Markdown
Contributor Author

what are the final compile flags that you're looking to suppress? I think adding these to the CI is in order, but I'm a bit confused as to what the flags are based on the PR description and commit error messages.

I wasn't thinking of suppressing any. Possibly adding an explicit set of warnings after having fixed those specific issues.

My bad -- I meant fix instead of suppress. The question still stands. What are those warnings? The PR description says one thing but individual commits show another.

Each commit is supposed to only fix the warning(s) mentioned in the four individual commit messages. For the PR, it could say "Fix clang++ warnings: -Wmissing-noreturn, -Wextra-semi, -Wextra-semi-stmt, -Wimplicit-fallthrough and -Wnrvo" but that'd require updating the PR message if I pull anything out of the set (or add anything to it).

@biojppm
Copy link
Copy Markdown
Owner

biojppm commented May 27, 2026

Looking at the failing windows tests : the newly-added C4_NORETURN to the tree handler events now causes a warning C4702: unreachable code on MSVC.

This is triggered from an engine test that checks for an error (ie requires an error) in the specified sequence of event handler calls when using the tree handler. That test must remain.

IMO the way to tackle this is to work around it by suppressing that warning it in the offending test source code: adding C4_SUPPRESS_WARNING_MSVC_WITH_PUSH(4702) and corresponding _POP at the top/bottom of the files.

AFAICT these are the files where that would be needed:

  • test/test_engine_3_map_block_2.cpp
  • test/test_engine_3_map_flow_1.cpp
  • test/test_engine_4_anchor.cpp
  • test/test_engine_5_tag_1.cpp
  • test/test_engine_6_qmrk_1.cpp
  • test/test_engine_6_qmrk_2.cpp
  • test/test_engine_6_qmrk_3.cpp
  • test/test_engine_6_qmrk_4.cpp
  • test/test_engine_7_seqimap.cpp

HTH.

@biojppm
Copy link
Copy Markdown
Owner

biojppm commented May 27, 2026

The failure in the coverage workflows is unrelated with this PR, and can be ignored. It's a token access problem that must be fixed elsewhere.

The install singleheader failure is a flaky test ; also unrelated.

TedLyngmo added 4 commits May 27, 2026 20:45
Signed-off-by: Ted Lyngmo <ted@lyncon.se>
This only fixes one simple case where named return value optimization
was prevented. The more complicated cases are still left.

Signed-off-by: Ted Lyngmo <ted@lyncon.se>
Signed-off-by: Ted Lyngmo <ted@lyncon.se>
Signed-off-by: Ted Lyngmo <ted@lyncon.se>
@biojppm
Copy link
Copy Markdown
Owner

biojppm commented May 27, 2026

I pushed a bunch of branches before approving this run. It's going to take a while.

@biojppm biojppm merged commit d8be67a into biojppm:master May 28, 2026
291 of 299 checks passed
@biojppm
Copy link
Copy Markdown
Owner

biojppm commented May 28, 2026

Thanks!

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.

3 participants