This is an automated email from the ASF dual-hosted git repository.

rmiddleton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git


The following commit(s) were added to refs/heads/master by this push:
     new 11f261b1 Fix build under GCC 12 #563 (#566)
11f261b1 is described below

commit 11f261b1f90bf4cc51d626f8192d7def1a78932d
Author: Robert Middleton <[email protected]>
AuthorDate: Sat Nov 29 21:54:57 2025 -0500

    Fix build under GCC 12 #563 (#566)
    
    * Fix build under GCC 12 #563
---
 src/main/cpp/asyncbuffer.cpp                   | 18 ++++++++--------
 src/main/include/log4cxx/helpers/asyncbuffer.h | 30 +++++++++++++++++---------
 src/test/cpp/asyncappendertestcase.cpp         |  4 ++--
 3 files changed, 31 insertions(+), 21 deletions(-)

diff --git a/src/main/cpp/asyncbuffer.cpp b/src/main/cpp/asyncbuffer.cpp
index f4233122..a0b0711f 100644
--- a/src/main/cpp/asyncbuffer.cpp
+++ b/src/main/cpp/asyncbuffer.cpp
@@ -17,9 +17,9 @@
 
 #include <log4cxx/helpers/asyncbuffer.h>
 #include <log4cxx/helpers/transcoder.h>
-#if defined(__cpp_concepts) && 202002 <= __cpp_concepts
+#if LOG4CXX_CONCEPTS
 #include <variant>
-#endif // defined(__cpp_concepts) && 202002 <= __cpp_concepts
+#endif // LOG4CXX_CONCEPTS
 
 namespace LOG4CXX_NS
 {
@@ -29,7 +29,7 @@ namespace helpers
 
 struct AsyncBuffer::Private
 {
-#if defined(__cpp_concepts) && 202002 <= __cpp_concepts && LOG4CXX_WCHAR_T_API
+#if LOG4CXX_CONCEPTS && LOG4CXX_WCHAR_T_API
     using value_t = std::variant<MessageBufferAppender, 
WideMessageBufferAppender>;
 #else // !(defined(__cpp_concepts) && 202002 <= __cpp_concepts && 
LOG4CXX_WCHAR_T_API)
     using value_t = MessageBufferAppender;
@@ -135,7 +135,7 @@ void AsyncBuffer::renderMessage(LogCharMessageBuffer& msg) 
const
        if (m_priv)
        {
                for (auto& renderer : m_priv->data)
-#if defined(__cpp_concepts) && 202002 <= __cpp_concepts && LOG4CXX_WCHAR_T_API
+#if LOG4CXX_CONCEPTS && LOG4CXX_WCHAR_T_API
                {
 #if LOG4CXX_LOGCHAR_IS_UTF8
                        if (auto pRenderer = 
std::get_if<MessageBufferAppender>(&renderer))
@@ -159,9 +159,9 @@ void AsyncBuffer::renderMessage(LogCharMessageBuffer& msg) 
const
                        }
 #endif // !LOG4CXX_LOGCHAR_IS_UTF8
                }
-#else // !(defined(__cpp_concepts) && 202002 <= __cpp_concepts && 
LOG4CXX_WCHAR_T_API)
+#else // !LOG4CXX_CONCEPTS
                        renderer(msg);
-#endif // !(defined(__cpp_concepts) && 202002 <= __cpp_concepts && 
LOG4CXX_WCHAR_T_API)
+#endif // !LOG4CXX_CONCEPTS
 
 #if LOG4CXX_ASYNC_BUFFER_SUPPORTS_FMT
 #if LOG4CXX_LOGCHAR_IS_UTF8
@@ -206,7 +206,7 @@ void AsyncBuffer::clear()
        }
 }
 
-#if defined(__cpp_concepts) && 202002 <= __cpp_concepts
+#if LOG4CXX_CONCEPTS
 /**
  *   Append \c function to this buffer.
  */
@@ -230,7 +230,7 @@ void AsyncBuffer::append(const WideMessageBufferAppender& f)
                m_priv->data.push_back(f);
 }
 #endif // LOG4CXX_WCHAR_T_API
-#else // !(defined(__cpp_concepts) && 202002 <= __cpp_concepts
+#else // !LOG4CXX_CONCEPTS
 /**
  *   Append \c function to this buffer.
  */
@@ -241,7 +241,7 @@ void AsyncBuffer::append(const MessageBufferAppender& f)
        else
                m_priv->data.push_back(f);
 }
-#endif // !(defined(__cpp_concepts) && 202002 <= __cpp_concepts
+#endif // !LOG4CXX_CONCEPTS
 
 } // namespace helpers
 } // namespace LOG4CXX_NS
diff --git a/src/main/include/log4cxx/helpers/asyncbuffer.h 
b/src/main/include/log4cxx/helpers/asyncbuffer.h
index 1784b358..7beb6894 100644
--- a/src/main/include/log4cxx/helpers/asyncbuffer.h
+++ b/src/main/include/log4cxx/helpers/asyncbuffer.h
@@ -27,7 +27,17 @@
 #include <fmt/xchar.h>
 #endif // LOG4CXX_WCHAR_T_API || LOG4CXX_LOGCHAR_IS_WCHAR
 #endif // LOG4CXX_ASYNC_BUFFER_SUPPORTS_FMT
-#if defined(__cpp_concepts) && 202002 <= __cpp_concepts
+
+#if defined(__cpp_concepts) && 202002 <= __cpp_concepts && defined(__GNUC__) 
&& __GNUC__ <= 12
+// GCC 12 has broken concepts
+#define LOG4CXX_CONCEPTS 0
+#elif defined(__cpp_concepts) && 202002 <= __cpp_concepts
+#define LOG4CXX_CONCEPTS 1
+#else
+#define LOG4CXX_CONCEPTS 0
+#endif
+
+#if LOG4CXX_CONCEPTS
 #include <concepts>
 #endif
 
@@ -65,7 +75,7 @@ public: // Operators
        template <typename T>
        AsyncBuffer& operator<<(const T& value)
        {
-#if defined(__cpp_concepts) && 202002 <= __cpp_concepts
+#if LOG4CXX_CONCEPTS
 #if LOG4CXX_LOGCHAR_IS_UTF8
                if constexpr (requires(std::ostream& buf, T v) { buf << v; })
                {
@@ -103,12 +113,12 @@ public: // Operators
                else
                        static_assert(false, "operator<<(std::wostream&) 
overload must be provided");
 #endif // !LOG4CXX_LOGCHAR_IS_UTF8
-#else // !(defined(__cpp_concepts) && 202002 <= __cpp_concepts)
+#else // !LOG4CXX_CONCEPTS
                append([value](LogCharMessageBuffer& msgBuf)
                        {
                                msgBuf << value;
                        });
-#endif // !(defined(__cpp_concepts) && 202002 <= __cpp_concepts)
+#endif // !LOG4CXX_CONCEPTS
                return *this;
        }
 
@@ -120,7 +130,7 @@ public: // Operators
        template <typename T>
        AsyncBuffer& operator<<(const T&& rvalue)
        {
-#if defined(__cpp_concepts) && 202002 <= __cpp_concepts
+#if LOG4CXX_CONCEPTS
 #if LOG4CXX_LOGCHAR_IS_UTF8
                if constexpr (requires(std::ostream& buf, T v) { buf << v; })
                {
@@ -158,12 +168,12 @@ public: // Operators
                else
                        static_assert(false, "operator<<(std::wostream&) 
overload must be provided");
 #endif // !LOG4CXX_LOGCHAR_IS_UTF8
-#else // !(defined(__cpp_concepts) && 202002 <= __cpp_concepts)
+#else // !LOG4CXX_CONCEPTS
                append([value = std::move(rvalue)](LogCharMessageBuffer& msgBuf)
                        {
                                msgBuf << value;
                        });
-#endif // !(defined(__cpp_concepts) && 202002 <= __cpp_concepts)
+#endif // !LOG4CXX_CONCEPTS
                return *this;
        }
 
@@ -215,7 +225,7 @@ private:
        AsyncBuffer& operator=(const AsyncBuffer&) = delete;
 
        LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(Private, m_priv)
-#if defined(__cpp_concepts) && 202002 <= __cpp_concepts
+#if LOG4CXX_CONCEPTS
        using MessageBufferAppender = std::function<void(CharMessageBuffer&)>;
 
        /**
@@ -231,14 +241,14 @@ private:
         */
        void append(const WideMessageBufferAppender& f);
 #endif // LOG4CXX_WCHAR_T_API
-#else // !(defined(__cpp_concepts) && 202002 <= __cpp_concepts)
+#else // !LOG4CXX_CONCEPTS
        using MessageBufferAppender = 
std::function<void(LogCharMessageBuffer&)>;
 
        /**
         *   Append \c f to this buffer.
         */
        void append(const MessageBufferAppender& f);
-#endif // !(defined(__cpp_concepts) && 202002 <= __cpp_concepts)
+#endif // !LOG4CXX_CONCEPTS
 
 #if LOG4CXX_ASYNC_BUFFER_SUPPORTS_FMT
        void initializeForFmt(StringViewType&& format_string, FmtArgStore&& 
args);
diff --git a/src/test/cpp/asyncappendertestcase.cpp 
b/src/test/cpp/asyncappendertestcase.cpp
index 36744924..871ce4a4 100644
--- a/src/test/cpp/asyncappendertestcase.cpp
+++ b/src/test/cpp/asyncappendertestcase.cpp
@@ -253,10 +253,10 @@ class AsyncAppenderTestCase : public 
AppenderSkeletonTestCase
 #if !LOG4CXX_LOGCHAR_IS_UTF8 || LOG4CXX_WCHAR_T_API
                        LOG4CXX_INFO(root, otherStr << 42);
                        ++expectedEventCount;
-#if defined(__cpp_concepts) && 202002 <= __cpp_concepts
+#if LOG4CXX_CONCEPTS
                        LOG4CXX_INFO_ASYNC(root, otherStr << 42);
                        ++expectedEventCount;
-#endif // defined(__cpp_concepts) && 202002 <= __cpp_concepts
+#endif // LOG4CXX_CONCEPTS
 #endif // !LOG4CXX_LOGCHAR_IS_UTF8 || LOG4CXX_WCHAR_T_API
 
                        // Check all messages were received

Reply via email to