toml11 icon indicating copy to clipboard operation
toml11 copied to clipboard

Brace constructing a toml::value inserts a new array element in GCC 10.2.1

Open andrewkcorcoran opened this issue 3 years ago • 2 comments

toml11v3.7.0

The toml2 variable in the below example is copy constructed incorrectly and has an empty array inserted on GCC but is correctly constructed on clang. The error looks to be to do with the toml::value std::intializer_list constructor std::enable_if being too broad (toml/value.hpp:840).

  #include <iostream>
  #include <sstream>

  #include "toml.hpp"

  int main()
  {
      auto stream = std::istringstream{"a = 1"};
      auto toml1 = toml::parse(stream);
      auto toml2 = toml::value{toml1};
      auto toml3 = toml::value(toml1);
      std::cout << toml1 << toml2 << toml3;
      return EXIT_SUCCESS;
  }
$ g++ --version
g++ (GCC) 10.2.1 20200804 (Red Hat 10.2.1-2)
./mva_gcc
a = 1
[[]]
a = 1
a = 1

$ clang++ --version
clang version 10.0.1 (Red Hat 10.0.1-4.el7)
./mva_clang
a = 1
a = 1
a = 1

andrewkcorcoran avatar Jun 23 '21 12:06 andrewkcorcoran

I am also having this issue

jackwil1 avatar Dec 22 '22 21:12 jackwil1