Skip to content

Conversation

@HazardyKnusperkeks
Copy link
Contributor

MinGW/GCC 10 report with -Wuseless-cast

What does this change do?

Fix three Warnings of casting T to `T´.

Is it related to an exisiting bug report or feature request?

No

Pre-merge checklist

  • I've read CONTRIBUTING.md
  • I've rebased my changes against the current HEAD of origin/master (if necessary)
  • I've added new test cases to verify my change
  • I've regenerated toml.hpp (how-to)
  • I've updated any affected documentation
  • I've rebuilt and run the tests with at least one of:
    • Clang 6 or higher
    • GCC 7 or higher (*)
    • Visual Studio 2019
  • I've given myself mad props by adding my name to the list of contributors in README.md

(*): MinGW/GCC 10: I needed two changes:

  1. I've had to comment out add_project_arguments(has_exceptions ? '-D_HAS_EXCEPTIONS=1' : '-D_HAS_EXCEPTIONS=0', language : 'cpp') otherwise it gets defined twice and results in an error:
FAILED: meson-out/cpp17_noexcept.exe.p/conformance_burntsushi_invalid.cpp.obj
"c++" "-Imeson-out/cpp17_noexcept.exe.p" "-Itests" "-I../tests" "-I../include" "-I../extern" "-fdiagnostics-color=always" "-pipe" "-D_FILE_OFFSET_BITS=64" "-Wall" "-Winvalid-pch" "-Wnon-virtual-dtor" "-Wextra" "-Wpedantic" "-Werror" "-std=c++17" "-fno-exceptions" "-g" "-march=native" "-fmax-errors=5" "-Wno-init-list-lifetime" "-Wcast-align" "-Wcast-qual" "-Wctor-dtor-privacy" "-Wdisabled-optimization" "-Wextra" "-Wfloat-equal" "-Wimport" "-Winit-self" "-Wlogical-op" "-Wmissing-declarations" "-Wmissing-field-initializers" "-Wmissing-format-attribute" "-Wmissing-include-dirs" "-Wmissing-noreturn" "-Wnoexcept" "-Wold-style-cast" "-Woverloaded-virtual" "-Wpacked" "-Wpadded" "-Wpedantic" "-Wpointer-arith" "-Wredundant-decls" "-Wshadow" "-Wsign-conversion" "-Wsign-promo" "-Wstack-protector" "-Wstrict-null-sentinel" "-Wswitch-default" "-Wswitch-enum" "-Wundef" "-Wunreachable-code" "-Wunused" "-Wunused-parameter" "-Wvariadic-macros" "-Wwrite-strings" "-Wmissing-noreturn" "-Wsuggest-attribute=const" "-Wsuggest-attribute=pure" "-D_ITERATOR_DEBUG_LEVEL=0" "-D_WINSOCK_DEPRECATED_NO_WARNINGS" "-D_SCL_SECURE_NO_WARNINGS" "-D_CRT_SECURE_NO_WARNINGS" "-D_HAS_EXCEPTIONS=1" "-fext-numeric-literals" "-DSHOULD_HAVE_EXCEPTIONS=0" "-D_HAS_EXCEPTIONS=0" "-DSHOULD_HAVE_INT128=1" "-DSHOULD_HAVE_FLOAT128=1" "-DTOML_UNRELEASED_FEATURES=0" "-DUSE_SINGLE_HEADER=1" -MD -MQ meson-out/cpp17_noexcept.exe.p/conformance_burntsushi_invalid.cpp.obj -MF "meson-out/cpp17_noexcept.exe.p/conformance_burntsushi_invalid.cpp.obj.d" -o meson-out/cpp17_noexcept.exe.p/conformance_burntsushi_invalid.cpp.obj "-c" ../tests/conformance_burntsushi_invalid.cpp
<command-line>: error: "_HAS_EXCEPTIONS" redefined [-Werror]
<command-line>: note: this is the location of the previous definition
cc1plus.exe: all warnings being treated as errors
  1. Deactivate the THIS_IS_AN_EVIL_MACRO because it modified std::min, std::numeric_limits::min, and the maxcounterparts. I don't know if this test is designed to work with MinGW, or just MSVC.

  2. Locales seem to work differently (or not at all?) with MinGW.

Anything else?

MinGW/GCC 10 report with -Wuseless-cast
@marzer
Copy link
Owner

marzer commented Dec 15, 2020

Hmmmm. Thanks for contributing, but the std::move replacement casts are deliberate. I was explicitly avoiding std::move by inlining it directly (easy win in debug builds). The warning is wrong. I'll disable it using pragmas instead.

Edit: Ah, apologies, the warning wasn't entirely wrong. I see now the PR does actually fix a few genuinely useless casts (including one that was a holdover I missed during refactoring).

The build system stuff is interesting. I'll look into that separately.

@marzer
Copy link
Owner

marzer commented Dec 15, 2020

Fixed in ea064da. I incorporated some of your fixes, and suppressed the rest with a pragma. Thanks for contributing!

@marzer marzer closed this Dec 15, 2020
@HazardyKnusperkeks HazardyKnusperkeks deleted the fix-warning branch December 16, 2020 06:28
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.

2 participants