Skip to content

Warnings with GCC 10 #2052

@nlohmann

Description

@nlohmann

With GCC 10.0.1 20200405 (experimental), the following warnings appear.

In file included from /usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/cassert:44,
                 from ../single_include/nlohmann/json.hpp:13540,
                 from src/unit-algorithms.cpp:32:
../single_include/nlohmann/json.hpp: In instantiation of 'static uint8_t nlohmann::detail::serializer<BasicJsonType>::decode(uint8_t&, uint32_t&, uint8_t) [with BasicJsonType = nlohmann::basic_json<>; uint8_t = unsigned char; uint32_t = unsigned int]':
../single_include/nlohmann/json.hpp:15002:27:   required from 'void nlohmann::detail::serializer<BasicJsonType>::dump_escaped(const string_t&, bool) [with BasicJsonType = nlohmann::basic_json<>; nlohmann::detail::serializer<BasicJsonType>::string_t = std::__cxx11::basic_string<char>]'
../single_include/nlohmann/json.hpp:14761:25:   required from 'void nlohmann::detail::serializer<BasicJsonType>::dump(const BasicJsonType&, bool, bool, unsigned int, unsigned int, bool) [with BasicJsonType = nlohmann::basic_json<>]'
../single_include/nlohmann/json.hpp:17727:19:   required from 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::string_t nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::dump(int, char, bool, nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::error_handler_t, bool) const [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; BinaryType = std::vector<unsigned char>; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::string_t = std::__cxx11::basic_string<char>; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::error_handler_t = nlohmann::detail::error_handler_t]'
../single_include/nlohmann/json.hpp:24020:25:   required from here
../single_include/nlohmann/json.hpp:15498:18: warning: comparison of unsigned expression in '>= 0' is always true [-Wtype-limits]
15498 |         assert(0 <= index and index < 400);
      |                ~~^~~~~~~~


In file included from /usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/ext/alloc_traits.h:34,
                 from /usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/bits/basic_string.h:40,
                 from /usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/string:55,
                 from /usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/bits/locale_classes.h:40,
                 from /usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/bits/ios_base.h:41,
                 from /usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/streambuf:41,
                 from /usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/bits/streambuf_iterator.h:35,
                 from /usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/iterator:66,
                 from ../single_include/nlohmann/json.hpp:44,
                 from src/unit-algorithms.cpp:32:
/usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/bits/alloc_traits.h: At global scope:
/usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/bits/alloc_traits.h:504:11: warning: noexcept-expression evaluates to 'false' because of a call to 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::internal_binary_t::internal_binary_t() [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; BinaryType = std::vector<unsigned char>]' [-Wnoexcept]
  504 |  noexcept(noexcept(::new((void*)__p) _Up(std::declval<_Args>()...)))
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from src/unit-algorithms.cpp:32:
../single_include/nlohmann/json.hpp:16380:9: note: but 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::internal_binary_t::internal_binary_t() [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; BinaryType = std::vector<unsigned char>]' does not throw; perhaps it should be declared 'noexcept'
16380 |         internal_binary_t() : BinaryType() {}
      |         ^~~~~~~~~~~~~~~~~
In file included from /usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/x86_64-apple-darwin19/bits/c++allocator.h:33,
                 from /usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/bits/allocator.h:46,
                 from /usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/string:41,
                 from /usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/bits/locale_classes.h:40,
                 from /usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/bits/ios_base.h:41,
                 from /usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/streambuf:41,
                 from /usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/bits/streambuf_iterator.h:35,
                 from /usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/iterator:66,
                 from ../single_include/nlohmann/json.hpp:44,
                 from src/unit-algorithms.cpp:32:
/usr/local/Cellar/gcc/HEAD-705510a/include/c++/10.0.1/ext/new_allocator.h:149:11: warning: noexcept-expression evaluates to 'false' because of a call to 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::internal_binary_t::internal_binary_t() [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; BinaryType = std::vector<unsigned char>]' [-Wnoexcept]
  149 |  noexcept(noexcept(::new((void *)__p)
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  150 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from src/unit-algorithms.cpp:32:
../single_include/nlohmann/json.hpp:16380:9: note: but 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::internal_binary_t::internal_binary_t() [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; BinaryType = std::vector<unsigned char>]' does not throw; perhaps it should be declared 'noexcept'
16380 |         internal_binary_t() : BinaryType() {}
      |         ^~~~~~~~~~~~~~~~~

src/unit-allocator.cpp: In function 'void _DOCTEST_ANON_FUNC_18()':
src/unit-allocator.cpp:275:24: warning: declaration of 'json' shadows a global declaration [-Wshadow]
  275 |         bad_alloc_json json;
      |                        ^~~~
In file included from src/unit-allocator.cpp:33:
../single_include/nlohmann/json.hpp:2763:7: note: shadowed declaration is here
 2763 | using json = basic_json<>;
      |       ^~~~

Metadata

Metadata

Assignees

Labels

kind: bugsolution: proposed fixa fix for the issue has been proposed and waits for confirmation

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions