Skip to content

Commit a82e3fa

Browse files
committed
Fix C++17 compilation error on FreeBSD GCC 13.3
Remove custom deduction guides for std::unique_ptr in C++17 mode. Issue: FreeBSD GCC 13.3 correctly rejects adding deduction guides to namespace std, which violates C++ standard [namespace.std]: "The behavior of a C++ program is undefined if it adds declarations or definitions to namespace std or to a namespace within namespace std." Root cause: The code attempted to add custom deduction guides for std::unique_ptr in namespace std when compiling in C++17 mode. This is not allowed by the C++ standard. Solution: Remove the custom deduction guides for C++17 and later, as the C++17 standard library already provides deduction guides for std::unique_ptr (added in C++17 via P0433R2). The custom deduction guide wrappers in the else branch (for C++14 and earlier) are kept as they provide helper functions, not actual deduction guides in namespace std. Tested-on: FreeBSD 15 with GCC 13.3 Fixes: Compilation error 'deduction guide must be declared in the same scope as template std::unique_ptr'
1 parent 543672b commit a82e3fa

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/libipc/platform/detail.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,9 @@
7272

7373
#if __cplusplus >= 201703L
7474

75-
namespace std {
7675

77-
// deduction guides for std::unique_ptr
78-
template <typename T>
79-
unique_ptr(T* p) -> unique_ptr<T>;
80-
template <typename T, typename D>
81-
unique_ptr(T* p, D&& d) -> unique_ptr<T, std::decay_t<D>>;
82-
83-
} // namespace std
76+
// C++17 and later: std library already provides deduction guides
77+
// No need to add custom ones, just use the standard ones directly
8478

8579
namespace ipc {
8680
namespace detail {

0 commit comments

Comments
 (0)