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

Warnings with Clang 10 #2049

Closed
nlohmann opened this issue Apr 19, 2020 · 3 comments · Fixed by #2051
Closed

Warnings with Clang 10 #2049

nlohmann opened this issue Apr 19, 2020 · 3 comments · Fixed by #2051
Assignees
Labels
kind: bug release item: 🔨 further change solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Milestone

Comments

@nlohmann
Copy link
Owner

With Clang 10.0.0, the following warnings appear.

../single_include/nlohmann/json.hpp:14558:53: warning: implicit conversion changes signedness: 'const int' to 'unsigned long' [-Wsign-conversion]
        return buf + (2 + static_cast<size_t>(-n) + k);
                                                  ~ ^
../single_include/nlohmann/json.hpp:14895:39: warning: implicit conversion loses integer precision: 'decltype(__x.base() - __y.base())' (aka 'long') to 'int'
      [-Wshorten-64-to-32]
                        int index = i - val.m_value.binary->cbegin();
                            ~~~~~   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../single_include/nlohmann/json.hpp:17727:15: note: in instantiation of member function 'nlohmann::detail::serializer<nlohmann::basic_json<std::map, std::vector,
      std::__1::basic_string<char>, bool, long long, unsigned long long, double, std::allocator, adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned
      char> > > >::dump' requested here
            s.dump(*this, true, ensure_ascii, static_cast<unsigned int>(indent), serialize_binary);
              ^
../single_include/nlohmann/json.hpp:24020:20: note: in instantiation of member function 'nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long
      long, unsigned long long, double, std::allocator, adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >::dump' requested here
        return h(j.dump());
                   ^

These lines were last changed in 0a82168 (#1967) and 012c966 (#1662).

nlohmann added a commit that referenced this issue Apr 19, 2020
@nlohmann nlohmann self-assigned this Apr 19, 2020
@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Apr 19, 2020
@nlohmann nlohmann added this to the Release 3.8.0 milestone Apr 20, 2020
@EliYk
Copy link

EliYk commented Apr 21, 2020

Hi,

On Ubuntu 16.04, with the following code in check.cpp:

#include <experimental/string_view>

namespace std {using std::experimental::string_view;}

#include "json.hpp"


int main (){
}

Attempting to compile with:

clang++-10 -std=c++2a -stdlib=libc++ check.cpp

I get :

In file included from check.cpp:5:
In file included from ./json.hpp:68:
In file included from /usr/include/c++/v1/unordered_map:369:
/usr/include/c++/v1/__hash_table:1132:43: error: exception specification in declaration does not match previous declaration
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table()
                                          ^
/usr/include/c++/v1/__hash_table:839:5: note: previous declaration is here
    __hash_table()
    ^
/usr/include/c++/v1/__hash_table:1200:43: error: exception specification in declaration does not match previous declaration
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u)
                                          ^
/usr/include/c++/v1/__hash_table:853:5: note: previous declaration is here
    __hash_table(__hash_table&& __u)
    ^
2 errors generated.

Not sure this is ticket-worthy, so I mentioned it here.

Thanks.
Eli

@nlohmann
Copy link
Owner Author

On Ubuntu 16.04, with the following code in check.cpp:

Which library version are you using?

@EliYk
Copy link

EliYk commented Apr 21, 2020

I apt removed existing libc++ libraries, reinstalled via -

sudo apt install libc++-10-dev libc++abi-10-dev (as per https://apt.llvm.org/)

Now it compiles, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug release item: 🔨 further change solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants