Skip to content

tomlplusplus_tests fails when building with libc++ on Linux #279

@kraj

Description

@kraj

Errors

 ./tests/tomlplusplus_tests

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tomlplusplus_tests is a Catch v2.13.10 host application.
Run with -? for options

-----------------------------------------------------------------------------------------------------------------------
conformance - burntsushi/invalid
  array-double-comma-1
-----------------------------------------------------------------------------------------------------------------------
../tests/conformance_burntsushi_invalid.cpp:583
.......................................................................................................................

../tests/tests.cpp:143: FAILED:
explicitly with messages:
  [conformance_burntsushi_invalid.cpp, line 585] parsing_should_fail("array = [1,,2]")
  Expected parsing failure, saw exception: Error while parsing array: expected value or closing ']', saw comma

-----------------------------------------------------------------------------------------------------------------------
conformance - burntsushi/invalid
  array-double-comma-2
-----------------------------------------------------------------------------------------------------------------------
../tests/conformance_burntsushi_invalid.cpp:588
.......................................................................................................................

../tests/tests.cpp:143: FAILED:
explicitly with messages:
  [conformance_burntsushi_invalid.cpp, line 590] parsing_should_fail("array = [1,2,,]")
  Expected parsing failure, saw exception: Error while parsing array: expected value or closing ']', saw comma

-----------------------------------------------------------------------------------------------------------------------
conformance - burntsushi/invalid
  array-extending-table
-----------------------------------------------------------------------------------------------------------------------
../tests/conformance_burntsushi_invalid.cpp:593
.......................................................................................................................

../tests/tests.cpp:143: FAILED:
explicitly with messages:
  [conformance_burntsushi_invalid.cpp, line 595] parsing_should_fail("a = [{ b = 1 }]

# Cannot extend tables within static arrays
  # https://github.com/toml-lang/toml/issues/908
  [a.c]
  foo = 1")
  Expected parsing failure, saw exception: Error while parsing table header: cannot redefine existing array 'a.c' as
  table

Environment

toml++ version and/or commit hash:

latest commit SHA1 - bf869b0

Compiler:
clang 20

C++ standard mode:
20

Target arch:
x64

Library configuration overrides:
None

Relevant compilation flags:
-stdlib=libc++

Describe the bug

There seems to a difference in exception handling between libc++ and libstdc++ where

When you build with libc++:

tomlplusplus correctly throws a toml::parse_error exception
The test's catch (const toml::parse_error& e) block fails to catch it due to ABI type matching issues
The exception propagates to a higher-level catch block that treats it as unexpected

When you build with libstdc++:

tomlplusplus correctly throws a toml::parse_error exception
The test's catch block successfully catches it using the same ABI
Test passes

Steps to reproduce (or a small repro code sample)

build using libc++ instead of libstdc++

CXX="clang++ -stdlib=libc++" LD='clang++ -stdlib=libc++' meson -Dbuild_tests=true build
ninja -C build
./build/tests/tomlplusplus_tests

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