Skip to content

‘<unnamed>.toml::detail::region::last_’ may be used uninitialized #267

@kontura

Description

@kontura

I have ran into a problem while converting to the 4.0.0 API.

Given:

#include <toml.hpp>

int main() {
  auto toml_data = toml::parse("./input.toml");
  std::vector<std::string> files = toml::get<std::vector<std::string>>(toml_data["files"]);
  toml::format(toml::value(toml::table{{"files", files}}));
  return 0;
}

I cannot compile with: g++ -O2 -Werror -Wuninitialized ./main.cpp

I am getting the following error:

In file included from /usr/include/toml11/region.hpp:4,
                 from /usr/include/toml11/fwd/source_location_fwd.hpp:4,
                 from /usr/include/toml11/source_location.hpp:4,
                 from /usr/include/toml11/fwd/error_info_fwd.hpp:4,
                 from /usr/include/toml11/error_info.hpp:4,
                 from /usr/include/toml11/context.hpp:4,
                 from /usr/include/toml.hpp:30,
                 from ./main.cpp:1:
In constructor ‘toml::detail::region::region(toml::detail::region&&)’,
    inlined from ‘toml::basic_value<TypeConcig>::basic_value(string_type, toml::string_format_info, std::vector<std::__cxx11::basic_string<char> >, region_type) [with TypeConfig = toml::type_config]’ at /usr/include/toml11/value.hpp:562:11,
    inlined from ‘toml::basic_value<TypeConcig>::basic_value(string_type) [with TypeConfig = toml::type_config]’ at /usr/include/toml11/value.hpp:548:100,
    inlined from ‘void std::_Construct(_Tp*, _Args&& ...) [with _Tp = toml::basic_value<toml::type_config>; _Args = {__cxx11::basic_string<char, char_traits<char>, allocator<char> >}]’ at /usr/include/c++/14/bits/stl_construct.h:119:7,
    inlined from ‘_ForwardIterator std::__do_uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = move_iterator<__gnu_cxx::__normal_iterator<__cxx11::basic_string<char>*, vector<__cxx11::basic_string<char> > > >; _ForwardIterator = toml::basic_value<toml::type_config>*]’ at /usr/include/c++/14/bits/stl_uninitialized.h:120:21:
/usr/include/toml11/fwd/region_fwd.hpp:49:5: error: ‘<unnamed>.toml::detail::region::first_’ may be used uninitialized [-Werror=maybe-uninitialized]
   49 |     region(region&&)      = default;
      |     ^~~~~~
In file included from /usr/include/toml11/types.hpp:8,
                 from /usr/include/toml11/get.hpp:7,
                 from /usr/include/toml11/find.hpp:6,
                 from /usr/include/toml11/conversion.hpp:4,
                 from /usr/include/toml.hpp:31:
/usr/include/toml11/value.hpp: In function ‘_ForwardIterator std::__do_uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = move_iterator<__gnu_cxx::__normal_iterator<__cxx11::basic_string<char>*, vector<__cxx11::basic_string<char> > > >; _ForwardIterator = toml::basic_value<toml::type_config>*]’:
/usr/include/toml11/value.hpp:548:87: note: ‘<anonymous>’ declared here
  548 |         : basic_value(std::move(x), string_format_info{}, std::vector<std::string>{}, region_type{})
      |                                                                                       ^~~~~~~~~~~~~
In constructor ‘toml::detail::region::region(toml::detail::region&&)’,
    inlined from ‘toml::basic_value<TypeConcig>::basic_value(string_type, toml::string_format_info, std::vector<std::__cxx11::basic_string<char> >, region_type) [with TypeConfig = toml::type_config]’ at /usr/include/toml11/value.hpp:562:11,
    inlined from ‘toml::basic_value<TypeConcig>::basic_value(string_type) [with TypeConfig = toml::type_config]’ at /usr/include/toml11/value.hpp:548:100,
    inlined from ‘void std::_Construct(_Tp*, _Args&& ...) [with _Tp = toml::basic_value<toml::type_config>; _Args = {__cxx11::basic_string<char, char_traits<char>, allocator<char> >}]’ at /usr/include/c++/14/bits/stl_construct.h:119:7,
    inlined from ‘_ForwardIterator std::__do_uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = move_iterator<__gnu_cxx::__normal_iterator<__cxx11::basic_string<char>*, vector<__cxx11::basic_string<char> > > >; _ForwardIterator = toml::basic_value<toml::type_config>*]’ at /usr/include/c++/14/bits/stl_uninitialized.h:120:21:
/usr/include/toml11/fwd/region_fwd.hpp:49:5: error: ‘<unnamed>.toml::detail::region::last_’ may be used uninitialized [-Werror=maybe-uninitialized]
   49 |     region(region&&)      = default;
      |     ^~~~~~
/usr/include/toml11/value.hpp: In function ‘_ForwardIterator std::__do_uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = move_iterator<__gnu_cxx::__normal_iterator<__cxx11::basic_string<char>*, vector<__cxx11::basic_string<char> > > >; _ForwardIterator = toml::basic_value<toml::type_config>*]’:
/usr/include/toml11/value.hpp:548:87: note: ‘<anonymous>’ declared here
  548 |         : basic_value(std::move(x), string_format_info{}, std::vector<std::string>{}, region_type{})
      |                                                                                       ^~~~~~~~~~~~~
cc1plus: all warnings being treated as errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions