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

3.6.0: warning: missing initializer for member 'std::array<char, 9ul>::_M_elems' [-Wmissing-field-initializers] #1527

Closed
ibc opened this issue Mar 20, 2019 · 6 comments
Assignees
Labels
confirmed kind: bug solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Milestone

Comments

@ibc
Copy link

ibc commented Mar 20, 2019

  • What is the issue you have?
In file included from ../src/xxxxx.hpp:5:0,
../include/json.hpp: In instantiation of 'std::string nlohmann::detail::lexer<BasicJsonType>::get_token_string() const [with BasicJsonType = nlohmann::basic_json<>; std::string = std::basic_string<char>]':
../include/json.hpp:7107:17:   required from 'void nlohmann::detail::parser<BasicJsonType>::parse(bool, BasicJsonType&) [with BasicJsonType = nlohmann::basic_json<>]'
../include/json.hpp:18993:9:   required from 'static nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer> nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parse(IteratorType, IteratorType, nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parser_callback_t, bool) [with IteratorType = const char*; typename std::enable_if<std::is_base_of<std::random_access_iterator_tag, typename std::iterator_traits<_InputIterator>::iterator_category>::value, int>::type <anonymous> = 0; ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parser_callback_t = std::function<bool(int, nlohmann::detail::parser<nlohmann::basic_json<> >::parse_event_t, nlohmann::basic_json<>&)>]'
../include/json.hpp:20793:42:   required from here
../include/json.hpp:6861:40: warning: missing initializer for member 'std::array<char, 9ul>::_M_elems' [-Wmissing-field-initializers]
                 std::array<char, 9> cs{};
                                        ^
  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?

Just include single_include/nlohmann/json.hpp into a C++ project and compile it in Linux.

Debian 8.11
gcc version 4.9.2 (Debian 4.9.2-10+deb8u1)

  • Did you use a released version of the library or the version from the develop branch?

3.6.0 git tag

@ibc ibc added the kind: bug label Mar 20, 2019
@ibc
Copy link
Author

ibc commented Mar 20, 2019

I think it may use {{}} as json.hpp already does in line 12811 and others:

/// a (hopefully) large enough character buffer
std::array<char, 64> number_buffer{{}};

This avoids the warning.

@nlohmann
Copy link
Owner

Strange: I compiled with GCC 9 and -Wmissing-field-initializers which did not trigger a warning. I'll check with GCC 4.9.

nlohmann added a commit that referenced this issue Mar 20, 2019
@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Mar 20, 2019
@nlohmann
Copy link
Owner

@ibc Could you please check if the issue is fixed with 7c55510?

@nlohmann nlohmann added this to the Release 3.6.1 milestone Mar 20, 2019
@nlohmann
Copy link
Owner


🔖 Release item

This issue/PR will be part of the next release of the library. This template helps preparing the release notes.

Type

  • ✨ New Feature
  • 🐛 Bug Fix
  • ⚡️ Improvement
  • 🔨 Further Change
  • 🔥 Deprecated function

Description


@nlohmann nlohmann self-assigned this Mar 20, 2019
@ibc
Copy link
Author

ibc commented Mar 20, 2019

Hi, yes, by adding double {{}} the warning does not happen. I already tested it yesterday :)

@nlohmann
Copy link
Owner

Cool, thanks!

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

No branches or pull requests

2 participants