]> git.hungrycats.org Git - bees/commitdiff
fd: fix VLA for Clang C++17
authorZygo Blaxell <bees@furryterror.org>
Wed, 18 Mar 2026 18:36:33 +0000 (14:36 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sat, 2 May 2026 03:48:58 +0000 (23:48 -0400)
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 <bees@furryterror.org>
lib/fd.cc

index 598b520926b68dc752828de088e8208bc0e35ce6..dbbfb48c054fa9e9f6e94768ed9991ca3c75860f 100644 (file)
--- 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<char> 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).