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

Starting with 3.10.4, just adding #include json.hpp causes compile error: `overload resolution selected deleted operator '=' #3620

Closed
guss77 opened this issue Jul 28, 2022 · 2 comments
Assignees
Labels
kind: bug release item: 🐛 bug fix solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@guss77
Copy link

guss77 commented Jul 28, 2022

Description

I've added the json.hpp file - as downloaded directly from the releases page - to my project and included it in one of my .cpp files. No other modification was done - the code itself is not used anyway, not even the recommended using instruction was added.

After that build of my Android application using clang 3.8.275480 break with this error:

.../json.hpp:4042:7: error: overload resolution selected deleted operator '='

Note:

After checking the develop version (as instructed at the bottom of the bug report form), I have concluded that this issue is already solved in the develop branch.

I'm still creating this ticket so other people who have this issue can find it, and possibly to be able to refer to it if develop will get unfixed at a later date.

Reproduction steps

  1. Download json.hpp of version 3.10.4 or 3.10.5 and add it to your project.
  2. Include it from one of your C++ files
  3. Try to compile the C++ file using clang 3.8 from Android NDK r14 with -std=c++14

Expected vs. actual results

The build should complete without errors, instead we get a build error (see below).

Minimal code example

Here's my test file, `test-json.cpp`:

++
#include "json.hpp"

int main() {
        return 0;
}


I'm building it with this command (it is highly simplified from the actual build command from the Android Gradle plugin and CMake, but should build the above test file successfully):

NDKROOT=/where/you/have/android-ndk-r14b;
SYSROOT=$NDKROOT/platforms/android-21/arch-x86_64;
LLVM_ARCH_LIBS=$NDKROOT/sources/cxx-stl/llvm-libc++/libs/x86_64/;
$NDKROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -cc1
-triple x86_64-none-linux-android
-I $NDKROOT/sources/cxx-stl/llvm-libc++/include
-I $SYSROOT/usr/include
-I $NDKROOT/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/3.8.275480/include
-std=c++14
-o test-json.cpp.o test-json.cpp


This build command completes correctly (i.e. no output) with `json.hpp` from 3.10.0 through 3.10.3.

Error messages

With `json.hpp` from releases 3.10.4 and 3.10.5, the following error output is emitted by the clang command show above:


In file included from test-json.cpp:1:
./json.hpp:4042:7: error: overload resolution selected deleted operator '='
    s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
    ~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./json.hpp:4401:16: note: in instantiation of function template specialization 'nlohmann::detail::from_json<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > >, nlohmann::detail::json_ref<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > > >, 0>' requested here
        return from_json(j, std::forward<T>(val));
               ^
./json.hpp:5060:9: note: in instantiation of function template specialization 'nlohmann::detail::from_json_fn::operator()<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > >, nlohmann::detail::json_ref<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > > > &>' requested here
        ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
        ^
./json.hpp:20574:36: note: in instantiation of function template specialization 'nlohmann::adl_serializer<nlohmann::detail::json_ref<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > > >, void>::from_json<const nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > > &, nlohmann::detail::json_ref<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > > > >' requested here
        JSONSerializer<ValueType>::from_json(*this, ret);
                                   ^
./json.hpp:20717:16: note: in instantiation of function template specialization 'nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > >::get_impl<nlohmann::detail::json_ref<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > > >, 0>' requested here
        return get_impl<ValueType>(detail::priority_tag<4> {});
               ^
./json.hpp:13488:15: note: candidate function has been explicitly deleted
    json_ref& operator=(json_ref&&) = delete;
              ^
./json.hpp:13487:15: note: candidate function has been explicitly deleted
    json_ref& operator=(const json_ref&) = delete;
              ^
In file included from test-json.cpp:1:
In file included from ./json.hpp:37:
In file included from /home/odeda/.local/Android/android-ndk-r14b/sources/cxx-stl/llvm-libc++/include/algorithm:634:
In file included from /home/odeda/.local/Android/android-ndk-r14b/sources/cxx-stl/llvm-libc++/include/memory:606:
/home/odeda/.local/Android/android-ndk-r14b/sources/cxx-stl/llvm-libc++/include/iterator:746:28: error: no member named 'insert' in 'std::initializer_list<nlohmann::detail::json_ref<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > > > >'
        {iter = container->insert(iter, _VSTD::move(__value_)); ++iter; return *this;}
                ~~~~~~~~~  ^
/home/odeda/.local/Android/android-ndk-r14b/sources/cxx-stl/llvm-libc++/include/algorithm:1957:19: note: in instantiation of member function 'std::__ndk1::insert_iterator<std::initializer_list<nlohmann::detail::json_ref<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > > > > >::operator=' requested here
        *__result = __op(*__first);
                  ^
./json.hpp:4167:10: note: in instantiation of function template specialization 'std::__ndk1::transform<nlohmann::detail::iter_impl<const nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > > >, std::__ndk1::insert_iterator<std::initializer_list<nlohmann::detail::json_ref<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > > > > >, (lambda at ./json.hpp:4169:9)>' requested here
    std::transform(
         ^
./json.hpp:4196:5: note: in instantiation of function template specialization 'nlohmann::detail::from_json_array_impl<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > >, std::initializer_list<nlohmann::detail::json_ref<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > > > >, 0>' requested here
    from_json_array_impl(j, arr, priority_tag<3> {});
    ^
./json.hpp:4401:16: note: in instantiation of function template specialization 'nlohmann::detail::from_json<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > >, std::initializer_list<nlohmann::detail::json_ref<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > > > >, 0>' requested here
        return from_json(j, std::forward<T>(val));
               ^
./json.hpp:5060:9: note: in instantiation of function template specialization 'nlohmann::detail::from_json_fn::operator()<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > >, std::initializer_list<nlohmann::detail::json_ref<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > > > > &>' requested here
        ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
        ^
./json.hpp:20574:36: note: in instantiation of function template specialization 'nlohmann::adl_serializer<std::initializer_list<nlohmann::detail::json_ref<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > > > >, void>::from_json<const nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > > &, std::initializer_list<nlohmann::detail::json_ref<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > > > > >' requested here
        JSONSerializer<ValueType>::from_json(*this, ret);
                                   ^
./json.hpp:20717:16: note: in instantiation of function template specialization 'nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > >::get_impl<std::initializer_list<nlohmann::detail::json_ref<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > > > >, 0>' requested here
        return get_impl<ValueType>(detail::priority_tag<4> {});
               ^
./json.hpp:4042:9: error: cannot pass object of non-trivial type 'const string_t' (aka 'const std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >') through variadic constructor; call will abort at runtime
    s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
        ^
./json.hpp:4401:16: note: in instantiation of function template specialization 'nlohmann::detail::from_json<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > >, std::__ndk1::__any, 0>' requested here
        return from_json(j, std::forward<T>(val));
               ^
./json.hpp:5060:9: note: in instantiation of function template specialization 'nlohmann::detail::from_json_fn::operator()<nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > >, std::__ndk1::__any &>' requested here
        ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
        ^
./json.hpp:20574:36: note: in instantiation of function template specialization 'nlohmann::adl_serializer<std::__ndk1::__any, void>::from_json<const nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > > &, std::__ndk1::__any>' requested here
        JSONSerializer<ValueType>::from_json(*this, ret);
                                   ^
./json.hpp:20717:16: note: in instantiation of function template specialization 'nlohmann::basic_json<std::map, std::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::allocator, adl_serializer, std::__ndk1::vector<unsigned char, std::__ndk1::allocator<unsigned char> > >::get_impl<std::__ndk1::__any, 0>' requested here
        return get_impl<ValueType>(detail::priority_tag<4> {});
               ^
3 errors generated.


### Compiler and operating system

clang 3.8.275480 on Ubuntu Linux with Android NDK r14

### Library version

3.10.4

### Validation

- [ ] The bug also occurs if the latest version from the [`develop`](https://github.com/nlohmann/json/tree/develop) branch is used.
- [ ] I can successfully [compile and run the unit tests](https://github.com/nlohmann/json#execute-unit-tests).
@guss77
Copy link
Author

guss77 commented Jul 28, 2022

As noted above, this issue seems to be already fixed in current develop.

I couldn't be bothered to bisect where it started and what fixed it - sorry 🤷 .

@guss77 guss77 closed this as completed Jul 28, 2022
@falbrechtskirchinger
Copy link
Contributor

Likely culprit: 0e694b4 #3073

Fixed by: 261cc4e #3427

@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Jul 28, 2022
@nlohmann nlohmann self-assigned this Jul 28, 2022
@nlohmann nlohmann added this to the Release 3.11.0 milestone Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug release item: 🐛 bug fix solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

3 participants