From 1555374980b9b9f6d5f13c33f7377008e80cdf46 Mon Sep 17 00:00:00 2001 From: Darryl Abbate Date: Fri, 12 Jun 2026 14:25:31 -0700 Subject: [PATCH] Fix C++20 build: don't name constructors with a template-id GCC 15 (the default compiler on Ubuntu 26.04) and other modern C++20 toolchains reject a template-id as a constructor declarator: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor] The DEFINE_INHERITED macro expands its first argument into the constructor declarator (`CLASS() { ... }`). For the templated benchmark classes, that argument was the full template-id, e.g. DEFINE_INHERITED(GLUE_TYPENAME(OriginalBenchmark), bs); which expands to `OriginalBenchmark() { ... }` -- a constructor named with a template-id, forbidden under C++20. Because IMB's Makefile builds with -Werror, this breaks the whole build on GCC 15. Pass the bare class name (the injected-class-name) instead of the template-id at the three templated call sites (OriginalBenchmark, BenchmarkMT, HaloBenchmark). Inside a class template the injected-class-name denotes the current instantiation, so both the `new CLASS` expression and the `CLASS()` constructor declarator remain correct, while the constructor is no longer spelled with a template-id. The non-templated call sites already pass a plain class name and are unchanged. Builds clean with GCC 15.2 (-Wall -Wextra -Werror, default C++17 and under -std=c++20) with no other changes. Signed-off-by: Darryl Abbate --- src_cpp/HALO/halo_benchmark.h | 2 +- src_cpp/MT/MT_benchmark.h | 2 +- src_cpp/helpers/original_benchmark.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src_cpp/HALO/halo_benchmark.h b/src_cpp/HALO/halo_benchmark.h index 5c5838c9d..8f4c6e348 100644 --- a/src_cpp/HALO/halo_benchmark.h +++ b/src_cpp/HALO/halo_benchmark.h @@ -295,7 +295,7 @@ class HaloBenchmark : public Benchmark { if (rank >= required_nranks) return; } - DEFINE_INHERITED(HaloBenchmark, bs); + DEFINE_INHERITED(HaloBenchmark, bs); }; } diff --git a/src_cpp/MT/MT_benchmark.h b/src_cpp/MT/MT_benchmark.h index 9650b2217..20a665ff5 100644 --- a/src_cpp/MT/MT_benchmark.h +++ b/src_cpp/MT/MT_benchmark.h @@ -487,5 +487,5 @@ template class BenchmarkMT : public BenchmarkMTBase { public: virtual void init_flags(); - DEFINE_INHERITED(GLUE_TYPENAME(BenchmarkMT), bs); + DEFINE_INHERITED(BenchmarkMT, bs); }; diff --git a/src_cpp/helpers/original_benchmark.h b/src_cpp/helpers/original_benchmark.h index 7922893c2..3c6c77827 100644 --- a/src_cpp/helpers/original_benchmark.h +++ b/src_cpp/helpers/original_benchmark.h @@ -229,6 +229,6 @@ class OriginalBenchmark : public Benchmark { ~OriginalBenchmark() { free(BMark[0].name); } - DEFINE_INHERITED(GLUE_TYPENAME(OriginalBenchmark), bs); + DEFINE_INHERITED(OriginalBenchmark, bs); };