Skip to content

build failure on upcoming gcc-12: test/src/unit-regression1.cpp:392:22: error: ambiguous overload for 'operator=' #3138

Closed
@trofi

Description

@trofi

On gcc-12 (20211107 snapshot) std::string amended it's constructors to a form that fails regression tests building:

mkdir b && cd b
cmake ..
make
...
[ 71%] Building CXX object test/CMakeFiles/test-regression1.dir/src/unit-regression1.cpp.o
/home/slyfox/dev/git/nlohmann-json/test/src/unit-regression1.cpp: In function 'void _DOCTEST_ANON_FUNC_2()':
/home/slyfox/dev/git/nlohmann-json/test/src/unit-regression1.cpp:392:22: error: ambiguous overload for 'operator=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'nlohmann::basic_json<>::value_type' {aka 'nlohmann::basic_json<>'})
  392 |         s2 = o["name"];
      |                      ^
In file included from /nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/string:53,
                 from /nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/bits/locale_classes.h:40,
                 from /nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/locale:39,
                 from /home/slyfox/dev/git/nlohmann-json/test/src/unit-regression1.cpp:33:
/nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/bits/basic_string.h:627:21: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::nullptr_t = std::nullptr_t]' (deleted)
  627 |       basic_string& operator=(nullptr_t) = delete;
      |                     ^~~~~~~~
/nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/bits/basic_string.h:682:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  682 |       operator=(const basic_string& __str)
      |       ^~~~~~~~
/nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/bits/basic_string.h:720:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  720 |       operator=(basic_string&& __str)
      |       ^~~~~~~~
In file included from /home/slyfox/dev/git/nlohmann-json/test/thirdparty/doctest/doctest_compatibility.h:6,
                 from /home/slyfox/dev/git/nlohmann-json/test/src/unit-regression1.cpp:30:
/home/slyfox/dev/git/nlohmann-json/test/src/unit-regression1.cpp:398:37: error: ambiguous overload for 'operator=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'nlohmann::basic_json<>::value_type' {aka 'nlohmann::basic_json<>'})
  398 |         CHECK_THROWS_AS(s2 = o["int"], json::type_error);
      |                                     ^
/home/slyfox/dev/git/nlohmann-json/test/thirdparty/doctest/doctest.h:1844:23: note: in definition of macro 'DOCTEST_CAST_TO_VOID'
 1844 |     static_cast<void>(__VA_ARGS__);                                                                \
      |                       ^~~~~~~~~~~
/home/slyfox/dev/git/nlohmann-json/test/thirdparty/doctest/doctest.h:2163:44: note: in expansion of macro 'DOCTEST_ASSERT_THROWS_AS'
 2163 | #define DOCTEST_CHECK_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_CHECK_THROWS_AS, "", __VA_ARGS__)
      |                                            ^~~~~~~~~~~~~~~~~~~~~~~~
/home/slyfox/dev/git/nlohmann-json/test/thirdparty/doctest/doctest.h:2576:36: note: in expansion of macro 'DOCTEST_CHECK_THROWS_AS'
 2576 | #define CHECK_THROWS_AS(expr, ...) DOCTEST_CHECK_THROWS_AS(expr, __VA_ARGS__)
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~
/home/slyfox/dev/git/nlohmann-json/test/src/unit-regression1.cpp:398:9: note: in expansion of macro 'CHECK_THROWS_AS'
  398 |         CHECK_THROWS_AS(s2 = o["int"], json::type_error);
      |         ^~~~~~~~~~~~~~~
In file included from /nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/string:53,
                 from /nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/bits/locale_classes.h:40,
                 from /nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/locale:39,
                 from /home/slyfox/dev/git/nlohmann-json/test/src/unit-regression1.cpp:33:
/nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/bits/basic_string.h:627:21: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::nullptr_t = std::nullptr_t]' (deleted)
  627 |       basic_string& operator=(nullptr_t) = delete;
      |                     ^~~~~~~~
/nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/bits/basic_string.h:682:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  682 |       operator=(const basic_string& __str)
      |       ^~~~~~~~
/nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/bits/basic_string.h:720:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  720 |       operator=(basic_string&& __str)
      |       ^~~~~~~~
In file included from /home/slyfox/dev/git/nlohmann-json/test/thirdparty/doctest/doctest_compatibility.h:6,
                 from /home/slyfox/dev/git/nlohmann-json/test/src/unit-regression1.cpp:30:
/home/slyfox/dev/git/nlohmann-json/test/src/unit-regression1.cpp:402:39: error: ambiguous overload for 'operator=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'nlohmann::basic_json<>::value_type' {aka 'nlohmann::basic_json<>'})
  402 |         CHECK_THROWS_WITH(s2 = o["int"], "[json.exception.type_error.302] type must be string, but is number");
      |                                       ^
/home/slyfox/dev/git/nlohmann-json/test/thirdparty/doctest/doctest.h:1844:23: note: in definition of macro 'DOCTEST_CAST_TO_VOID'
 1844 |     static_cast<void>(__VA_ARGS__);                                                                \
      |                       ^~~~~~~~~~~
/home/slyfox/dev/git/nlohmann-json/test/thirdparty/doctest/doctest.h:2167:46: note: in expansion of macro 'DOCTEST_ASSERT_THROWS_WITH'
 2167 | #define DOCTEST_CHECK_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, #expr, DT_CHECK_THROWS_WITH, __VA_ARGS__)
      |                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/slyfox/dev/git/nlohmann-json/test/thirdparty/doctest/doctest.h:2577:38: note: in expansion of macro 'DOCTEST_CHECK_THROWS_WITH'
 2577 | #define CHECK_THROWS_WITH(expr, ...) DOCTEST_CHECK_THROWS_WITH(expr, __VA_ARGS__)
      |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/slyfox/dev/git/nlohmann-json/test/src/unit-regression1.cpp:402:9: note: in expansion of macro 'CHECK_THROWS_WITH'
  402 |         CHECK_THROWS_WITH(s2 = o["int"], "[json.exception.type_error.302] type must be string, but is number");
      |         ^~~~~~~~~~~~~~~~~
In file included from /nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/string:53,
                 from /nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/bits/locale_classes.h:40,
                 from /nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/locale:39,
                 from /home/slyfox/dev/git/nlohmann-json/test/src/unit-regression1.cpp:33:
/nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/bits/basic_string.h:627:21: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::nullptr_t = std::nullptr_t]' (deleted)
  627 |       basic_string& operator=(nullptr_t) = delete;
      |                     ^~~~~~~~
/nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/bits/basic_string.h:682:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  682 |       operator=(const basic_string& __str)
      |       ^~~~~~~~
/nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/bits/basic_string.h:720:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  720 |       operator=(basic_string&& __str)
      |       ^~~~~~~~
/home/slyfox/dev/git/nlohmann-json/test/src/unit-regression1.cpp:1174:16: error: ambiguous overload for 'operator=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'nlohmann::json' {aka 'nlohmann::basic_json<>'})
 1174 |         test = v;
      |                ^
In file included from /nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/string:53,
                 from /nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/bits/locale_classes.h:40,
                 from /nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/locale:39,
                 from /home/slyfox/dev/git/nlohmann-json/test/src/unit-regression1.cpp:33:
/nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/bits/basic_string.h:627:21: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::nullptr_t = std::nullptr_t]' (deleted)
  627 |       basic_string& operator=(nullptr_t) = delete;
      |                     ^~~~~~~~
/nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/bits/basic_string.h:682:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  682 |       operator=(const basic_string& __str)
      |       ^~~~~~~~
/nix/store/0hvbmcf38gqpr6c49h7zl3iy228afaz0-gcc-12.0.0/include/c++/12.0.0/bits/basic_string.h:720:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  720 |       operator=(basic_string&& __str)
      |       ^~~~~~~~
make[2]: *** [test/CMakeFiles/test-regression1.dir/build.make:76: test/CMakeFiles/test-regression1.dir/src/unit-regression1.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2148: test/CMakeFiles/test-regression1.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

Which compiler and operating system are you using?

  • Compiler: gcc-12 development snapshot
  • Operating system: x86_64-linux

Which version of the library did you use?

  • the develop branch

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions