Skip to content

Assert in unique_ptr::operator* #169

@ncaklovic

Description

@ncaklovic

Environment

TOML++ version 3.2.0

Compiler:
GCC 10

C++ standard mode:
C++ 17

Library configuration overrides:
TOML_ENABLE_FORMATTERS 0
TOML_EXCEPTIONS 0

Describe the bug

Assert in unique_ptr::operator*

Steps to reproduce (or a small repro code sample)

Use value in TOML whih does not parse, like

[a]
b = [c"]

Additional information

  • parser::parse_array() calls array::emplace_back() even if parse_value() fails
  • array::emplace_back() does insert_at_back() and return *elems_.back(); - which is dereferencing nullptr.
  • dereferencing nullptr is undefined behavior - MSVC lets it pass, but GCC (libstdcpp) has proper assert.

The simplest fix probably would be something like 4a4bf1e. I didn't do PR because I would expect that some of the tests running on GCC already found the problem.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions