Closed
Description
Compiling tests with gcc and the -std flag set to gnu++20 or c++20, leads to compilation issues.
What is the issue you have?
More precisely, the u8"" literals have changed with the C++20 standard via P0482 in a non backward-compatible way char8_t
is not the same as unsigned char
.
When we compile the test suite of the project we get the following kind of errors with gcc:
In file included from json-3.9.1/test/thirdparty/doctest/doctest_compatibility.h:6,
from json-3.9.1/test/src/unit-class_parser.cpp:30:
json-3.9.1/test/thirdparty/doctest/doctest.h: In instantiation of 'doctest::detail::Result doctest::detail::Expression_lhs<L>::operator==(const R&) [with R = char8_t [5]; L = const std::__cxx11::basic_string<char>&]':
json-3.9.1/test/src/unit-class_parser.cpp:513:17: required from here
json-3.9.1/test/thirdparty/doctest/doctest.h:1119:32: error: no match for 'operator==' (operand types are 'const std::__cxx11::basic_string<char>' and 'const char8_t [5]')
1119 | #define DOCTEST_CMP_EQ(l, r) l == r
| ^
This comes from the following type of line which is not correct now:
CHECK(parser_helper("\"\\ud80c\\udc60\"").get<json::string_t>() == u8"\U00013060");
As there are many ways to cope with this in the code (for instance described here, I let the maintainers decide which one fits the best.
Please describe the steps to reproduce the issue.
Build it the standard way
mkdir -p _build
cd _build
cmake ..
make V=1 -j8
Relevant environment variables:
- CXXFLAGS=' -std=gnu++20 -fno-working-directory -ggdb3'
- LDFLAGS=' -fno-working-directory -ggdb3'
Can you provide a small but working code example?
We can warkaround the problem by disabling the char8_t
support with the -fno-char8_t
compiler option.
What is the expected behavior?
Compilation with no error
And what is the actual behavior instead?
See above.
Which compiler and operating system are you using?
- Compiler: gcc 11 (developement version)
- Operating system: GNU/Linux ubuntu 20.04
Which version of the library did you use?
- [x ] latest release version 3.9.1
- other release - please state the version: ___
- the
develop
branch
If you experience a compilation error: can you compile and run the unit tests?
- yes
- [x ] no - please copy/paste the error message below