[BUG] Invoking executable without args gives regex error
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 1.8k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 8
Description
**Describe the bug**
When I run the following benchmark setup I always see the message `Failed to match any benchmarks against regex: .` when I invoke the executable (giving `--help` causes a segfault
**System**
Which OS, compiler, and compiler version are you using:
- OS: Debian 10 for WSL2
- Compiler and version: gcc 8.3
**To reproduce**
Steps to reproduce the behavior:
1. Create a new directory
2. Place this CMakeLists.txt in that directory:
```cmake
cmake_minimum_required(VERSION 3.14)
project(my_project)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
include(FetchContent)
set(BENCHMARK_ENABLE_TESTING off)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.0)
FetchContent_Declare(
googlebenchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG v1.7.0)
FetchContent_MakeAvailable(
googletest
googlebenchmark)
find_package(OpenMP)
add_library(
libbench
bench.cpp)
target_link_libraries(
libbench
PRIVATE
benchmark::benchmark
pthread
OpenMP::OpenMP_CXX)
add_executable(bench /dev/null)
target_link_libraries(
bench
PRIVATE
libbench
benchmark::benchmark_main
OpenMP::OpenMP_CXX)
```
3. Use this `.cpp` file
* or write your own as far as I can tell it doesn't matter
* unsure if all these headers matter but I've left them in case they do
```cpp
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
static void BM_vector_push_back(benchmark::State& state) {
for (auto _ : state) {
std::vector v;
v.reserve(1);
benchmark::DoNotOptimize(v.data()); // Allow v.data() to be clobbered.
v.push_back(42);
benchmark::ClobberMemory(); // Force 42 to be written to memory.
}
}
BENCHMARK(BM_vector_push_back);
```
4. `cmake -DCMAKE_BUILD_TYPE=Release -S . -B build`
5. `cmake --build build -- -j8`
6. `./build/bench`
7. See error, Step 8 should've run the `BM_vector_push_back` test but instead it says `Failed to match any benchmarks against regex: .` and fails.
BONUS:
8. if you run `build/bench --help` you'll see a segmentation fault
**Expected behavior**
I expect all benchmarks in the cpp file to have been run. (in this case `BM_vector_push_back`) Additionally I expected command line argument parsing to function correctly
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Additional context**
The project where I noticed this problem previously used gcc directly and referred to artifacts that were created manually. I want to use cmake's `FetchContent` in that project instead this.
Contributor guide
Assessment
This issue has not been assessed yet.