From 2dc0263e7b0082cab680c91a7fc87f6753865d6e Mon Sep 17 00:00:00 2001 From: "Aleksei (Faumaray) Selikhov" Date: Sat, 5 Dec 2026 14:32:12 +0300 Subject: [PATCH] fuzz: fall back to the newest C++ standard clang accepts --- fuzz/run.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/fuzz/run.sh b/fuzz/run.sh index b0aabff..00012d1 100755 --- a/fuzz/run.sh +++ b/fuzz/run.sh @@ -16,7 +16,21 @@ if [ -d "$root/fuzz/seeds" ]; then cp -n "$root/fuzz/seeds/"* "$corpus/" 2>/dev/null || true fi -clang++ -std=c++26 -O1 -g -fsanitize=fuzzer,address,undefined \ +# Use the newest C++ standard the installed Clang accepts (older distributions stop at +# C++23, spelled c++2b there). +std_flag="${VBS_FUZZ_STD:-}" +if [ -z "$std_flag" ]; then + for candidate in c++26 c++2b c++23; do + if clang++ "-std=$candidate" -fsyntax-only -x c++ /dev/null >/dev/null 2>&1; then + std_flag="$candidate" + break + fi + done +fi +: "${std_flag:?clang++ accepts none of c++26/c++2b/c++23}" +echo "fuzzing with -std=$std_flag" + +clang++ "-std=$std_flag" -O1 -g -fsanitize=fuzzer,address,undefined \ -fno-omit-frame-pointer \ -I"$root/include" -I"$root/recipes" -I"$VOID_INCLUDE_DIR" \ "$root/fuzz/fuzz_parsers.cpp" -o "$out/fuzz_parsers"