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

Make comparisons not ambiguous (fixes clang warnings) #1703

Merged
merged 1 commit into from
Nov 2, 2024

Conversation

heinezen
Copy link
Member

We previoulsy had a bunch of clang warnings that looked like this:

/home/chantal/repo/libopenage/coord/coord_test.cpp:60:5: warning: ISO C++20 considers use of overloaded operator '!=' (with operand types 'openage::coord::tests::(anonymous namespace)::TestCoordsAbsolute' and 'openage::coord::tests::(anonymous namespace)::TestCoordsAbsolute') to be ambiguous despite there being a unique best viable function with non-reversed arguments [-Wambiguous-reversed-operator]
    TESTEQUALS(a0, a1);
    ^~~~~~~~~~~~~~~~~~
/home/chantal/repo/libopenage/coord/../testing/testing.h:53:25: note: expanded from macro 'TESTEQUALS'
                        if (test_result_left != (right)) { \
                            ~~~~~~~~~~~~~~~~ ^  ~~~~~~~
/home/chantal/repo/.bin/clang++-debug-Oauto-sanitize-none/libopenage/coord/coord_xy.gen.h:86:17: note: candidate function with non-reversed arguments
        constexpr bool operator !=(const Absolute &other) const {
                       ^
/home/chantal/repo/.bin/clang++-debug-Oauto-sanitize-none/libopenage/coord/coord_xy.gen.h:82:17: note: ambiguous candidate function with reversed arguments
        constexpr bool operator ==(const Absolute &other) const {'

These were the result of a few changes to the C++20 standard. The warnings were exclusively located in the coordinate system templates.

I think I fixed this issue now by removing the operator!= implementation (which should be generated implicitely now) and using a different operator== overload. This gets rid of the warnings completely.

@heinezen heinezen added lang: c++ Done in C++ code code quality Does not alter behavior, but beauty of our code bugfix Restores intended behavior kevin-rebuild-pl0x instruct kevin to rebuild this pull request labels Oct 31, 2024
@SFTbot SFTbot removed the kevin-rebuild-pl0x instruct kevin to rebuild this pull request label Oct 31, 2024
@heinezen heinezen added the kevin-rebuild-pl0x instruct kevin to rebuild this pull request label Oct 31, 2024
@SFTbot SFTbot removed the kevin-rebuild-pl0x instruct kevin to rebuild this pull request label Oct 31, 2024
@heinezen heinezen force-pushed the fix/ambiguous_compare branch from 0a5a65f to 65d2f7a Compare November 1, 2024 17:29
@TheJJ TheJJ merged commit 45a7dd5 into SFTtech:master Nov 2, 2024
13 checks passed
@heinezen heinezen deleted the fix/ambiguous_compare branch November 25, 2024 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Restores intended behavior code quality Does not alter behavior, but beauty of our code lang: c++ Done in C++ code
Projects
Development

Successfully merging this pull request may close these issues.

3 participants