This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

Solaris 10 doesn't follow POSIX in accepting a null pointer as the
second argument to realpath(), so allocate a buffer for it.

Tested x86_64-linux, committed to trunk.

commit ed4023452f85f6c745ce473b2503f4e46fb02cd9
Author: Jonathan Wakely <>
Date:   Fri Sep 11 15:19:27 2015 +0100

    Fix filesystem::canonical on Solaris 10.
    	PR libstdc++/67173
    	* src/filesystem/ (filesystem::canonical): Allocate buffer for
    	realpath on Solaris 10.

diff --git a/libstdc++-v3/src/filesystem/ b/libstdc++-v3/src/filesystem/
index 661685a..cefb927 100644
--- a/libstdc++-v3/src/filesystem/
+++ b/libstdc++-v3/src/filesystem/
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <errno.h>
+#include <limits.h>  // PATH_MAX
 # include <unistd.h>
@@ -97,7 +98,11 @@ fs::canonical(const path& p, const path& base, error_code& ec)
   path can;
-  if (char_ptr rp = char_ptr{::realpath(absolute(p, base).c_str(), nullptr)})
+  char* buffer = nullptr;
+#if defined(__SunOS_5_10) && defined(PATH_MAX)
+  buffer = (char*)::malloc(PATH_MAX);
+  if (char_ptr rp = char_ptr{::realpath(absolute(p, base).c_str(), buffer)})

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]