From: Zygo Blaxell Date: Wed, 18 Mar 2026 18:36:33 +0000 (-0400) Subject: fd: fix VLA for Clang C++17 X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=515380dfa24ef7d439046d57c005354f47c2cfab;p=bees fd: fix VLA for Clang C++17 Upgrading to -std=c++17 exposed a variable-length array in C++17 that causes build failure on Clang. Replace with standard-compliant forms so the normal build works with both compilers. Signed-off-by: Zygo Blaxell --- diff --git a/lib/fd.cc b/lib/fd.cc index 598b5209..dbbfb48c 100644 --- a/lib/fd.cc +++ b/lib/fd.cc @@ -530,14 +530,14 @@ namespace crucible { // Start with a reasonable guess since it will usually work off_t size = 4096; while (size < 1048576) { - char buf[size + 1]; + vector buf(size + 1); int rv; - DIE_IF_MINUS_ONE(rv = readlink(path.c_str(), buf, size + 1)); + DIE_IF_MINUS_ONE(rv = readlink(path.c_str(), buf.data(), size + 1)); // No negative values allowed except -1 THROW_CHECK1(runtime_error, rv, rv >= 0); if (rv <= size) { buf[rv] = 0; - return buf; + return buf.data(); } // cerr << "Retrying readlink(" << path << ", buf, " << size + 1 << ")" << endl; // This is from the Linux readlink(2) man page (release 3.44).