fix #1446 by removing the address operator (#1538)

* fix #1446 by removing the address operator

* add test

* format

---------

Co-authored-by: Thomas <thomas.maierbacher@rohde-schwarz.com>
Co-authored-by: Dominic Hamon <dominichamon@users.noreply.github.com>
This commit is contained in:
dominic 2023-02-06 17:34:47 +01:00 committed by GitHub
parent 4c9cee34f2
commit ff8d44c928
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -1379,7 +1379,7 @@ class Fixture : public internal::Benchmark {
BENCHMARK_PRIVATE_DECLARE(_benchmark_) = \
(::benchmark::internal::RegisterBenchmarkInternal( \
new ::benchmark::internal::FunctionBenchmark(#__VA_ARGS__, \
&__VA_ARGS__)))
__VA_ARGS__)))
#else
#define BENCHMARK(n) \
BENCHMARK_PRIVATE_DECLARE(n) = \

View File

@ -5,6 +5,7 @@
#include <stdint.h>
#include <chrono>
#include <complex>
#include <cstdlib>
#include <iostream>
#include <limits>
@ -254,4 +255,16 @@ static void BM_BenchmarkName(benchmark::State& state) {
}
BENCHMARK(BM_BenchmarkName);
// regression test for #1446
template <typename type>
static void BM_templated_test(benchmark::State& state) {
for (auto _ : state) {
type created_string;
benchmark::DoNotOptimize(created_string);
}
}
static auto BM_templated_test_double = BM_templated_test<std::complex<double>>;
BENCHMARK(BM_templated_test_double);
BENCHMARK_MAIN();