Closed kawashima-fj closed 5 months ago
The bodies of the BENCHMARK macros in src_cpp/*/*_benchmark.cpp is wrongly ordered. For example, BENCHMARK(IMB_pingpong, PingPong) is expaneded as the following code. elem_PingPong is instantiated before name and descr are specialized.
BENCHMARK
src_cpp/*/*_benchmark.cpp
BENCHMARK(IMB_pingpong, PingPong)
elem_PingPong
name
descr
template class OriginalBenchmark<BenchmarkSuite<BS_MPI1>, IMB_pingpong>; namespace { OriginalBenchmark<BenchmarkSuite<BS_MPI1>,IMB_pingpong> elem_PingPong; } template<> const char *OriginalBenchmark<BenchmarkSuite<BS_MPI1>,IMB_pingpong>::name = "PingPong"; template<> smart_ptr<Bmark_descr> OriginalBenchmark<BenchmarkSuite<BS_MPI1>, IMB_pingpong>::descr = __null; template<> bool OriginalBenchmark<BenchmarkSuite<BS_MPI1>, IMB_pingpong>::init_description()
This causes the following compilation error with clang++.
clang++
MPI1/MPI1_benchmark.cpp:79:1: error: explicit specialization of 'name' after instantiation BENCHMARK(IMB_pingpong, PingPong) ^ MPI1/MPI1_benchmark.cpp:73:107: note: expanded from macro 'BENCHMARK' #define BENCHMARK(BMRK_FN, BMRK_NAME) template class OriginalBenchmark<BenchmarkSuite<BS_MPI1>, BMRK_FN>; \ ^ ./benchmark.h:88:114: note: expanded from macro '\ DECLARE_INHERITED_TEMPLATE' #define DECLARE_INHERITED_TEMPLATE(CLASS, NAME) namespace { CLASS elem_ ## NAME; } template<> const char *CLASS::name = #NAME; ^ helpers/original_benchmark.h:139:34: note: implicit instantiation first required here BMark->name = strdup(name); ^
This changes have already unstreamed in product. Thank you for contribution :)
The bodies of the
BENCHMARK
macros insrc_cpp/*/*_benchmark.cpp
is wrongly ordered. For example,BENCHMARK(IMB_pingpong, PingPong)
is expaneded as the following code.elem_PingPong
is instantiated beforename
anddescr
are specialized.This causes the following compilation error with
clang++
.