Description
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
- Download
json.hpp
of version 3.10.4 or 3.10.5 and add it to your project. - Include it from one of your C++ files
- 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).