Package: libboost-url1.92.0
Source: boost1.92
Version: 1.92.0-4+b1
Severity: important
Tags: upstream patch
Control: forwarded -1 https://github.com/boostorg/url/issues/1006

Dear Maintainer,

Since the library is now built with GCC 16 (default -std=gnu++20), the shared
library libboost_url.so.1.92.0 no longer exports the error category objects
boost::urls::detail::error_cat, boost::urls::grammar::detail::error_cat and
boost::urls::grammar::detail::condition_cat. Any consumer compiled as C++17
(or older) fails to link against it.

Root cause (upstream, since Boost 1.91): boost/url/impl/error.hpp and
boost/url/grammar/impl/error.hpp declare the categories differently depending
on the language standard of the including translation unit:

    #if defined(BOOST_URL_HAS_CXX20_CONSTEXPR)
    inline constexpr error_cat_type error_cat{};
    inline constexpr condition_cat_type condition_cat{};
    #else
    BOOST_URL_DECL extern error_cat_type error_cat;
    BOOST_URL_DECL extern condition_cat_type condition_cat;
    #endif

When the library is built as C++20, the objects are inline variables without
a visibility attribute, so with -fvisibility=hidden they are not exported.
A C++17 consumer takes the "extern" branch and references them as external
symbols, which cannot be resolved.

Steps to reproduce (sid/forky, g++ 16.2.0-4, libboost-url1.92-dev 1.92.0-4+b1):

    $ cat t.cpp
    #include <boost/url/parse.hpp>
    #include <iostream>
    int main() {
        auto r = boost::urls::parse_uri("http://example.com/";);
        std::cout << r.has_value() << std::endl;
    }

    $ g++ -std=c++17 t.cpp -o t -lboost_url
    /usr/bin/ld: 
t.cpp:(.text._ZN5boost4urls7grammar15make_error_codeENS1_5errorE[...]+0x12):
      undefined reference to `boost::urls::grammar::detail::error_cat'
    /usr/bin/ld: 
t.cpp:(.text._ZN5boost4urls7grammar20make_error_conditionENS1_9conditionE[...]+0xe):
      undefined reference to `boost::urls::grammar::detail::condition_cat'
    collect2: error: ld returned 1 exit status

    $ g++ -std=c++20 t.cpp -o t -lboost_url && ./t
    1

    $ nm -DC /usr/lib/x86_64-linux-gnu/libboost_url.so.1.92.0 | grep -E ' 
(error|condition)_cat$'
    (no output - only typeinfo/vtable for *_cat_type are exported)

Expected: C++17 consumers link fine, as they did with boost1.90 (and as is
the case with the static library built for the matching standard).

Upstream status: reported as boostorg/url#1006 and fixed by boostorg/url#1009
(merged to develop on 2026-10-16, commit
0df4f4651b40be62312f5f1ffffc35523ddd6dc5), which is not part of 1.92.0.
The relevant part of the fix marks the inline objects as visible so that
a C++20-built shared library exports them:

--- a/include/boost/url/grammar/impl/error.hpp
+++ b/include/boost/url/grammar/impl/error.hpp
@@ -119,7 +119,12 @@ struct BOOST_SYMBOL_VISIBLE
 };

 #if defined(BOOST_URL_HAS_CXX20_CONSTEXPR)
+// Visible so a shared library built as C++20
+// still exports the symbols that consumers built
+// as C++17 reference through the externs below
+BOOST_SYMBOL_VISIBLE
 inline constexpr error_cat_type error_cat{};
+BOOST_SYMBOL_VISIBLE
 inline constexpr condition_cat_type condition_cat{};
 #else
 BOOST_URL_DECL extern error_cat_type error_cat;

(and the same change for boost::urls::detail::error_cat in
include/boost/url/impl/error.hpp).

Could you please backport the error-category part of upstream PR #1009 to
boost1.92? Projects that pin C++17 (CMAKE_CXX_STANDARD 17, -std=gnu++17)
and use Boost.URL currently fail to build in sid/forky.

Best regards,
Roman Ondráček

Reply via email to