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>
// 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).