From 2216843fd5327d05152f4959e65f7eb76ee7994d Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Tue, 13 Aug 2024 06:03:15 -0400 Subject: [PATCH] cm_cxx_filesystem: Improve detection of std::filesystem support on GCC The check added by commit 40af103402 (cmCMakePath: do not use std::filesystem::path with RH gcc-toolset-10, 2023-12-02, v3.28.0~5^2) fails unnecessarily in some cases due to not inheriting `std::string_view` publicly. Inheritance into a class is private by default, and this std class has public members that would be access restricted when used to create public objects in the current scope. On some versions of GCC, depending on standards options, this causes either template instantiation errors, or "inaccessible base" or "not declared" errors. Fix by setting the inheritance to public. This does not affect the intention of the previous fix because the check still fails when using gcc-toolset-10's standard library with clang. Issue: #25458, #25453 --- Source/Checks/cm_cxx_filesystem.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Checks/cm_cxx_filesystem.cxx b/Source/Checks/cm_cxx_filesystem.cxx index bdc7c6d743..456ec46c84 100644 --- a/Source/Checks/cm_cxx_filesystem.cxx +++ b/Source/Checks/cm_cxx_filesystem.cxx @@ -47,7 +47,7 @@ int main() #if defined(__GLIBCXX__) // RH gcc-toolset-10 has a strange bug: it selects, in some circumstances, // the wrong constructor which generate error in template instantiation. - class my_string_view : std::string_view + class my_string_view : public std::string_view { public: my_string_view(const char* p)