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

Ambiguous equality/inequality operators under C++20 #631

Open
tonyelewis opened this issue Mar 19, 2020 · 2 comments
Open

Ambiguous equality/inequality operators under C++20 #631

tonyelewis opened this issue Mar 19, 2020 · 2 comments

Comments

@tonyelewis
Copy link

@tonyelewis tonyelewis commented Mar 19, 2020

Running clang++ -x c++ -std=c++2a -isystem include include/cereal/archives/json.hpp with a trunk version of Clang in the root of the cereal repo, gives:

In file included from include/cereal/archives/json.hpp:67:
include/cereal/external/rapidjson/document.h:813:58: error: use of overloaded operator '!=' is ambiguous (with operand types 'rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> >::MemberIterator' (aka 'rapidjson::GenericMemberIterator<false, rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> >') and 'rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> >::MemberIterator')
                for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m)
                                                       ~ ^  ~~~~~~~~~~~
include/cereal/external/rapidjson/document.h:2150:5: note: in instantiation of member function 'rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> >::~GenericValue' requested here
    GenericDocument(Allocator* allocator = 0, size_t stackCapacity = kDefaultStackCapacity, StackAllocator* stackAllocator = 0) :
    ^
include/cereal/archives/json.hpp:435:7: note: in instantiation of member function 'rapidjson::GenericDocument<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>, rapidjson::CrtAllocator>::GenericDocument' requested here
      JSONInputArchive(std::istream & stream) :
      ^
include/cereal/external/rapidjson/document.h:179:10: note: candidate function
    bool operator!=(ConstIterator that) const { return ptr_ != that.ptr_; }
         ^
include/cereal/external/rapidjson/document.h:178:10: note: candidate function
    bool operator==(ConstIterator that) const { return ptr_ == that.ptr_; }
         ^
include/cereal/external/rapidjson/document.h:178:10: note: candidate function (with reversed parameter order)
1 error generated.

AFAIU, the reworking of comparisons in C++20 means that the new language must now reject some previously acceptable code for causing ambiguities between comparison operators that the compiler could consider (eg see discussion here https://bugs.llvm.org/show_bug.cgi?id=43765#c4 ).

@erichkeane
Copy link
Contributor

@erichkeane erichkeane commented Mar 19, 2020

There's a handful of core-issues against C++20 about this, I'm hopeful they will fix this situation in some way.

The alternative I think is to add non-const versions of those comparisons to rapidjson (as this is an issue with that library).

groscoe2 added a commit to groscoe2/cereal that referenced this issue May 28, 2020
Based on Tencent/rapidjson#1679
Addresses USCiLab#631
@tonyelewis
Copy link
Author

@tonyelewis tonyelewis commented Aug 24, 2020

Do the above references to this issue suggest that grabbing an updated version of rapidjson would solve this problem?

relay-everything added a commit to relay-everything/cereal that referenced this issue Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.