Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silenced compiler warnings #77675

Merged
merged 6 commits into from
Nov 11, 2024

Conversation

PatrikLundell
Copy link
Contributor

Summary

None

Purpose of change

Silence a bunch of compiler warnings (with the rather futile hope to one day reach a state where the appearance of a warning means it's something you've just caused, and thus needs to deal with).

Describe the solution

  • Silenced a template type conversion complaint fouling the compile log with a bunch of references every compilation by turning an implicit conversion into an explicit on.
  • Changed obviously incorrect && into || (being different from at least one of two flags will always be true). Cannot guarantee the change is the correct one, but looks reasonable.
  • Changed bitwise comparisons into the boolean ones they probably were meant to be.
  • Changed a whole lot of loop variables into const & ones (const sometimes present already) after checking if they seems to actually be assigned (found none in my checks).

Describe alternatives you've considered

Also trying to silence many of the complaints about switch fallthroughs. It appears C++17 has the [[fallthrough]]; directive the compiler can interpret (rather than the various human produced comments present in a lot of cases).
Haven't tried to do it as I'm not completely certain that will work for all compilers used by the project.

Testing

Loaded save, walked up ramp, jumped into car, ran through hay bales, ran over a turkey, smashed into a stationary vehicle. Didn't see anything odd.

Additional context

There are a lot of warnings about:

  • Access via null pointers (some reasoning being incorrect, such as assuming casting of a Creature into an npc resulting in a nullptr must mean casting into a monster also has to result in a nullptr). Many may be relevant, though.
  • Stack footprint of operations being excessive.
  • Use of a moved from object.
  • Stuff in imgui and flatbuffer, but I assume they're "as is" and shouldn't be touched, as they're marked as third party.
  • Some odd bits and ends, some of which seems to be the compiler making assumptions it cannot logically make with the information available.

@github-actions github-actions bot added NPC / Factions NPCs, AI, Speech, Factions, Ownership Map / Mapgen Overmap, Mapgen, Map extras, Map display Vehicles Vehicles, parts, mechanics & interactions Mutations / Traits / Professions/ Hobbies Mutations / Traits / Professions/ Hobbies Code: Tests Measurement, self-control, statistics, balancing. [C++] Changes (can be) made in C++. Previously named `Code` Character / World Generation Issues and enhancements concerning stages of creating a character or a world Mechanics: Enchantments / Spells Enchantments and spells json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Nov 8, 2024
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Nov 8, 2024
@Night-Pryanik Night-Pryanik merged commit 5ba11c4 into CleverRaven:master Nov 11, 2024
19 of 26 checks passed
@PatrikLundell PatrikLundell deleted the warnings_buster branch November 11, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Character / World Generation Issues and enhancements concerning stages of creating a character or a world Code: Tests Measurement, self-control, statistics, balancing. json-styled JSON lint passed, label assigned by github actions Map / Mapgen Overmap, Mapgen, Map extras, Map display Mechanics: Enchantments / Spells Enchantments and spells Mutations / Traits / Professions/ Hobbies Mutations / Traits / Professions/ Hobbies NPC / Factions NPCs, AI, Speech, Factions, Ownership Vehicles Vehicles, parts, mechanics & interactions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants