Commit 0de59ca3 authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

travis: fix segfault for clang 8

The travis clang-8 reports a SIGILL with the code:

    std::string str = "    ";
    Ensures(baryonyx::left_trim(str) == "");

Fix the problem using .empty() instead of operator==.

- travis:
  - use `-O2` seems to fix a segfault in the testlib unit test.
  - execute test with gdb
parent ddf30d08
Pipeline #5296 passed with stage
in 3 minutes and 13 seconds
......@@ -15,6 +15,7 @@ addons:
apt:
packages: &common_packages
- cmake
- gdb
env:
matrix:
......@@ -78,10 +79,6 @@ matrix:
- *common_packages
- clang-8
- g++-7
# osx is disabled. We are waiting for a 10.14:
# /benchmark.cpp:607:12:
# error: call to unavailable function 'visit': introduced in macOS 10.14
#
- os: osx
osx_image: xcode11.2
env: CXX_COMPILER=clang++ CXXSTD=c++17
......@@ -91,14 +88,14 @@ install:
- cd baryonyx
- mkdir build
- cd build
- CXXFLAGS="-O3 -std=$CXXSTD" cmake -DCMAKE_CXX_COMPILER=$CXX_COMPILER -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_COLOR_MAKEFILE=OFF -DCMAKE_VERBOSE_MAKEFILE=ON ..
- CXXFLAGS="-std=$CXXSTD" cmake -DCMAKE_CXX_COMPILER=$CXX_COMPILER -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_COLOR_MAKEFILE=OFF -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
script:
- make
- sudo make install
- ctest -V -R testio
- ctest -V -R testlib
- ctest -V -R testsolver
- gdb ./lib/testio -ex run -ex bt -ex kill -ex quit
- gdb ./lib/testlib -ex run -ex bt -ex kill -ex quit
- gdb ./lib/testsolver -ex run -ex bt -ex kill -ex quit
notifications:
email:
......
......@@ -59,10 +59,10 @@ left_trim(std::string_view s) noexcept
{
auto found = s.find_first_not_of(" \t\n\v\f\r");
if (found == std::string::npos)
if (found == std::string_view::npos)
return {};
return s.substr(found, std::string::npos);
return s.substr(found, std::string_view::npos);
}
/**
......@@ -77,7 +77,7 @@ right_trim(std::string_view s) noexcept
{
auto found = s.find_last_not_of(" \t\n\v\f\r");
if (found == std::string::npos)
if (found == std::string_view::npos)
return {};
return s.substr(0, found + 1);
......
......@@ -762,18 +762,18 @@ check_trim_functions()
{
std::string str = " ";
Ensures(baryonyx::left_trim(str) == "");
Ensures(baryonyx::right_trim(str) == "");
Ensures(baryonyx::trim(str) == "");
Ensures(baryonyx::left_trim(str).empty());
Ensures(baryonyx::right_trim(str).empty());
Ensures(baryonyx::trim(str).empty());
Ensures(str == " ");
}
{
std::string str = "";
Ensures(baryonyx::left_trim(str) == "");
Ensures(baryonyx::right_trim(str) == "");
Ensures(baryonyx::trim(str) == "");
Ensures(str == "");
Ensures(baryonyx::left_trim(str).empty());
Ensures(baryonyx::right_trim(str).empty());
Ensures(baryonyx::trim(str).empty());
Ensures(str.empty());
}
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment