Flatpak is the new name of xdg-app. So following up on my previous LibreOffice in a Box post, here is some more technical detail on how an upcoming LibreOffice 5.2 will be available as a Flatpak bundle.

There is now a shell script demonstrating how to do all the downloading of sources, building, and bundling up. I decided against using flatpak-builder (nee xdg-app-builder) for that mostly out of convenience, mainly because the way LibreOffice fetches its external dependencies is so different from the typical way of building a Linux app. So I felt more comfortable doing these things manually, calling the raw xdg-app build steps from a script. But given enough pressure (e.g., to make the LibreOfficeKit widget buried within the LibreOffice installation set available to other Flatpak apps), this might get revisited.

The script proceeds in six steps (see the above link for details):

First, building LibreOffice requires an Archive-Zip Perl module not found in the org.gnome.Sdk we build against. The easiest solution (easier than to try and get rid of that Perl dependency in the LibreOffice build machinery, that is) is to download it and make it available to the build via the PERLLIB environment variable.

Second, we need the LibreOffice sources themselves. The current master branch has all the necessary changes needed for a Flatpak’ed LibreOffice (as will the coming libreoffice-5-2 branch).

Third, we need to fetch LibreOffice’s external dependencies. LibreOffice has a long list of external projects that it can either use from the underlying system or build/bundle itself. Those external projects covered by Flatpak’s org.gnome.Platform runtime are taken from there, but whatever remains is bundled with the LibreOffice app. The sources for these external projects are normally downloaded during the build, but an xdg-app build does not have network connectivity, so they need to be downloaded upfront. So bootstrap enough of a LibreOffice build here to execute the make fetch part.

Fourth, LibreOffice is built in xdg-app. The choice of building against the org.gnome.Platform 3.20 is somewhat arbitrarty, but it’s the latest revision available. And given LibreOffice’s strong GTK3 support (which e.g. also enables running on Wayland), this should make the resulting app more versatile than basing it on the more fundamental org.freedesktop.Platform. Building LibreOffice doesn’t exactly follow the make && make install mantra, but there happened to already be a make distro-pack-install target that produces the build artifacts in (almost) the right way for our purposes here.

Fifth, the build artifacts from the previous step are assembled in the way xdg-app expects them. Some of the metadata desktop and icon files need to be renamed, to match xdg-app’s expectation that metadata files belonging to the org.libreoffice.LibreOffice app have names actually starting with “org.libreoffice.LibreOffice”.

Finally, everything is bundled up into a LibreOffice.flatpak that can be distributed to users, who can then install it with xdg-app install --bundle LibreOffice.flatpak.

The bundle contains all the available LibreOffice localizations. It doesn’t make that much of a difference for the size of the resulting LibreOffice.flatpak, and should be easier to handle for both producers and consumers than to provide dedicated single-language apps. For reasons of size, the help content is not bundled, though; the intent is to (transparently) use the online help content. However, one caveat with the current state of xdg-app is that an app cannot reach out to other applications on the machine via xdg-open (a portal will be needed for that). When asked to process “external” URLs (e.g., when clicking on a hyperlink in a text document, but also when accessing the online help), LibreOffice tries to pass those URLs to xdg-open, but that doesn’t work yet in xdg-app.


Between an assert and a [[fallthrough]]

LibreOffice now has Clang -Wimplicit-fallthrough enabled to catch places where a break has been missing between cases in a switch statement. See “Re: clang -Wimplicit-fallthrough and missing breaks” for some further details.

Of course, a code base as large as LibreOffice has quite a number of places where such fall-through from one case to the next is intentional, and where warnings thus need to be suppressed. The solution is the [[clang::fallthrough]] annotation (which will be available as plain [[fallthrough]] in C++17), wrapped up as a SAL_FALLTHROUGH macro for now (so it doesn’t confuse other compilers).

All fine and dandy.

Until you realise that there is quite a number of places like the following in the code base:

Foo * p;
switch (kind) {
    assert(false); // cannot happen
case Kind1:
    p = new Foo(1);
case Kind2:
    p = new Foo(2);
case Kind3:
    p = new Foo(3);

Maybe kind is of an enumeration type that can only legitimately take on one of the values Kind1Kind3 (see “”enum union” with set of values restricted to exactly its enumerators?” for a discussion how such a type cannot reasonably be modeled in C++), or it is a type that can take on a wider set of values, but some invariant guarantee is that it will only take on values Kind1Kind3 here. Regardless, some compilers will warn about unhandled cases, and/or about p being used uninitialized in some cases. So the default assert part got added at some point in time, logcially marking any unhandled cases as unreachable. If a compiler/NDEBUG-configuration combo is smart enough to conclude that the assert is non-returning, it will not emit a warning. If, on the other hand, the compiler/NDEBUG-configuration combo assumes fall-through to case Kind1, it will not emit a warning about p being used uninitialized, either.

All fine and dandy.

Except that, in the NDEBUG case, Clang will now warn about a missing [[fallthrough]] annotation between the default branch and case Kind1. Under non-NDEBUG configuration (i.e., assert actually expands to some code), it is smart enough to conclude that the assert(false) will never return, so it concludes that there will be no fall-through, so will not warn. But under NDEBUG configuration (i.e., the assert expands to nothing), it sees an empty statement in the default branch, causing fall-through, causing a -Wimplicit-fallthrough warning.

But when you add a [[fallthrough]] annotation to appease the NDEBUG configuration, the non-NDEBUG configuration will start to complain about an unreachable [[fallthrough]] annotation (as it considers the assert to be non-returning, see above).

Caught between a rock and a hard place.

One way out is to rewrite the code as follows:

Foo * p;
switch (kind) {
case Kind1:
    p = new Foo(1);
case Kind2:
    p = new Foo(2);
case Kind3:
    p = new Foo(3);
    for (;;) std::abort(); // cannot happen

The std::abort marks the default branch as dead independent of NDEBUG. The infinite loop around it is there to make even the most lame compiler aware that that statement will not return, so it will refrain from emitting a warning about p being used uninitialized. (And the default branch can now go at the end, where it feels more naturally at home.)

And no, there should be no fears that the second variant will behave differently now in production NDEBUG builds. In the first variant, should kind ever take on an invalid value, it would silently treat it as Kind1, proceeding (though, of course, proceeding in the most unfortunate of “defensive programming” ways), not (immediately) crashing in the user’s face. In the second variant, it would abort outright (“crashing in the user’s face!”, one might fear). But that’s a red herring. The assert (and, similarly, the std::abort) codifies the invariant that kind must be one of Kind1Kind3 here. So if it ever did have a different value, all bets about the state of the program would be off, anyway. And it would better fail fast.

libc++/libc++abi on Linux

LibreOffice bug report “Build failure with clang++/libc++ on Linux x86_64” and reports about a similar failure when trying to build on NetBSD made me look at building LibreOffice on Linux with Clang against libc++/libc++abi (instead of the usual libstdc++) myself.

The libc++ web site warns: “Unfortunately you can’t simply run clang with ‘-stdlib=libc++’ at this point [when you have built Clang to be able to use libc++ in combination with libc++abi], as clang is set up to link for libc++ linked to libsupc++.” But that appears to no longer be true (at least on current LLVM trunk). All it takes is to include the libcxx and libcxxabi repositories in the projects sub-directory of the LLVM/Clang source tree and build it. The resulting includes the necessary -lc++abi, so building LibreOffice with CXX=clang++ -stdlib=libc++ just works. (You need to make sure that the gets found at runtime, of course, e.g., by setting LD_LIBRARY_PATH.)

One remaining problem is that libc++abi and libstdc++ (resp. its ABI-related libsupc++ part) differ in how they determine type equivalence. On the one hand, libc++abi sticks to the original C++ ABI semantics: “It is intended that two type_info pointers point to equivalent type descriptions if and only if the pointers are equal.” (That is, type equivalence is determined by comparing _ZTI* type_info pointers for equality.) On the other hand, libstdc++ relaxed this quite a while ago to comparing type_infos’ name fields (_ZTS*) for string equality (via strcmp).

While both approaches have pros and cons, they do lead to different behaviour. One example is when a dynamic library is dlopen’ed RTLD_LOCAL. If code in that library (or any library that gets loaded dependent of it) throws an exception of type T, and code beyond that RTLD_LOCAL “wall” shall catch it, then that will work with the libstdc++ approach but fail with the libc++abi approach (even if all the relevant _ZTI*, _ZTS* symbols are weakly exported).

That is the reason why e.g. the UNO runtime makes sure to dlopen all relevant libraries as RTLD_GLOBAL, but LibreOfficeKit/LibreOfficeKitInit.h somewhat ignorantly tries to get away with dlopen’ing the sofficeapp library as RTLD_LOCAL. Now LibreOffice’s cppunittester executable (used to run CppUnit tests during the LibreOffice build) links against the sal library. So by the time CppunitTest_libreofficekit_tiledrendering dlopen’s the sofficeapp library as RTLD_LOCAL, the sal library has already been loaded into the process (implicitly as RTLD_GLOBAL), so any UNO components that happen to get instantiated in that process (via the dlopen in sal’s osl_loadModule) will be outside that “sofficeapp RTLD_LOCAL walled garden,” so that when code in ucb/source/ucp/file/bc.cxx throws a css::ucb::CommandFailedException, code in ucbhelper/source/client/content.cxx (inside the walled garden) won’t catch it (but would instead proceed to std::unexpected, std::terminate, std::abort).

That problematic dlopen with RTLD_LOCAL had already been addressed for UBSan builds (where runtime type identification code in at least Clang’s UBSan implementation always operates under the original C++ ABI semantics, regardless of compiler ABI library used), “Ensure RTTI symbol visibility for Linux Clang -fsanitize=function,vptr.” The only problem this time is to find a suitable #if condition to distinguish usage of libc++abi from usage of other compiler ABI libraries, “[cfe-dev] Feature-test macro whether compiling against libc++abi?”


Some notes on building LibreOffice master (towards LO 5.2) with recent GCC trunk (towards GCC 6.0):

  • I ran into two open bugs with GCC that for now need workaround patches to be applied to LO:
  • (There was also another test breaker that took a while to track down as “Make sure desktop under LOK does not see osl_setCommandArgs CommandLineArgs.” But that one was not caused by any sort of mis-compilation, but rather by the fact that LO, when mistakenly asked to open a dynamic library as a document, happens to auto-detect an ELF library built by GCC 6 as a MacPaint document, while it auto-detected such libraries built with older GCC versions as plain text Writer documents.)
  • All the other (minor) fixes and tweaks have gone into the LO code base by now, and make check succeeded for me for both an (implicitly) --disable-debug as well as an --enable-dbgutil build (on some random Fedora 22 Linux box).
  • (With the caveat of having to --disable-firebird-sdbc in the --disable-debug case due to some error during building of that notorious external module,
    make -f ../gen/Makefile.refDatabases empty_db
    make[4]: Entering directory 'lo/core/workdir/UnpackedTarball/firebird/gen'
    make -f ../gen/Makefile.static.createdb
    make[5]: Entering directory 'lo/core/workdir/UnpackedTarball/firebird/gen'
    make[5]: Nothing to be done for 'all'.
    make[5]: Leaving directory 'lo/core/workdir/UnpackedTarball/firebird/gen'
    rm -f empty.fdb
    ../gen/firebird/bin/create_db empty.fdb
    invalid request BLR at offset 24
    -Too many Contexts of Relation/Procedure/Views. Maximum allowed is 255
    ../gen/Makefile.refDatabases:66: recipe for target 'empty.fdb' failed
    make[4]: *** [empty.fdb] Error 254
    make[4]: Leaving directory 'lo/core/workdir/UnpackedTarball/firebird/gen'
    Makefile:275: recipe for target 'empty_db' failed
    make[3]: *** [empty_db] Error 2
    make[3]: Leaving directory 'lo/core/workdir/UnpackedTarball/firebird/gen'
    Makefile:6: recipe for target 'firebird_embedded' failed
    make[2]: *** [firebird_embedded] Error 2
    make[2]: Leaving directory 'lo/core/workdir/UnpackedTarball/firebird'
    lo/core/external/firebird/ recipe for target 'lo/core/workdir/ExternalProject/firebird/build' failed
    make[1]: *** [lo/core/workdir/ExternalProject/firebird/build] Error 1

    which I have not been able to track down yet.)

  • The most common new warning encountered was -Werror=misleading-indentation. We already have a Clang loplugin:bodynotinblock (“compiler plugin check for if/while/true bodies with possibly {} missing”), so this new GCC warning did not find any more errors, but it does warn about cases where an additional statement follows a complete if statement on the same line, like in “-Werror=misleading-indentation (GCC 6).”
  • The diagnostic information presented by the compiler when it finds an error in the code has improved still with GCC 6, but unfortunately the most dreaded
    lo/core/sw/source/core/text/txtfrm.cxx: In member function ‘virtual bool SwTextFrame::Prepare(PrepareHint, const void*, bool)’:
    lo/core/sw/source/core/text/txtfrm.cxx:689:0: error: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Werror=strict-overflow]
          if( nLen != COMPLETE_STRING && GetOfst() > nPos + nLen ) // the range preceded us

    emitted when building with optimizations enabled still leaves you completely clueless about what is going on, like in “Silence some odd -Werror=strict-overflow (GCC 6).”

  • (And PR66460 “ICE using __func__ in constexpr function” is still open, so we still have the somewhat unfortunate situation that we detect HAVE_CXX14_CONSTEXPR=1 in the --disable-debug case, but HAVE_CXX14_CONSTEXPR=0 in the --enable-debug case—or its --enable-dbgutil superset, or its --enable-assert-always-abort subset.)

(Update 2016-02-25: Current LibreOffice master builds fine now with recent GCC trunk rev. 233691 out of the box; no more workarounds needed on either side.)


Program 1:

#define min(a, b) ((a) < (b) ? (a) : (b))
struct S { static int const n = 0; };
int main() { return min(S::n, 1); }

Program 2:

#include <algorithm>
struct S { static int const n = 0; };
int main() { return std::min(S::n, 1); }

Program 3:

#include <algorithm>
struct S { static int const n = 0; };
int main() { return std::min({S::n, 1}); }

Where is the bug?

Right, program 2 lacks a definition of S::n.

std::min(T const &, T const &) takes its arguments by reference, so S::n does get odr-used there.

std::min(std::initializer_list<T>) does not have that gotcha.

LibreOffice in a Box

I had the pleasure of presenting my initial work on packaging LibreOffice as a sandboxed xdg-app bundle at GUADEC over the weekend.

Additionally, I dumped my experimental xdg-app repo for my LibreOffice build at now.  It is built off the current libreoffice-5-0-1 branch, with an autogen.input consisting of


and some local patch

diff --git a/external/redland/ b/external/redland/
index eaffcf1..dbc0649 100644
--- a/external/redland/
+++ b/external/redland/
@@ -48,7 +48,7 @@ $(call gb_ExternalProject_get_state_target,raptor,build):
 			$(if $(CROSS_COMPILING),--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)) \
 			$(if $(filter MACOSX,$(OS)),--prefix=/@.__________________________________________________OOO) \
 			$(if $(filter IOS ANDROID,$(OS)),--disable-shared,--disable-static) \
-			$(if $(SYSTEM_LIBXML),,--with-xml2-config=$(call gb_UnpackedTarball_get_dir,xml2)/xml2-config) \
+			$(if $(SYSTEM_LIBXML),--without-xml2-config,--with-xml2-config=$(call gb_UnpackedTarball_get_dir,xml2)/xml2-config) \
 		&& $(MAKE) \
diff --git a/fpicker/ b/fpicker/
index c109dce..7ce952d 100644
--- a/fpicker/
+++ b/fpicker/
@@ -13,6 +13,7 @@ $(eval $(call gb_Library_Library,fps_office))
 $(eval $(call gb_Library_set_componentfile,fps_office,fpicker/source/office/fps_office))
 $(eval $(call gb_Library_use_external,fps_office,boost_headers))
+$(eval $(call gb_Library_use_external,fps_office,gio))
 $(eval $(call gb_Library_use_custom_headers,fps_office,\
 	officecfg/registry \
diff --git a/fpicker/source/office/OfficeFilePicker.cxx b/fpicker/source/office/OfficeFilePicker.cxx
index 6fd28ed..40698aa 100644
--- a/fpicker/source/office/OfficeFilePicker.cxx
+++ b/fpicker/source/office/OfficeFilePicker.cxx
@@ -43,6 +43,8 @@
 #include "osl/mutex.hxx"
 #include "vcl/svapp.hxx"
+#include <gio/gio.h>
 // using ----------------------------------------------------------------
 using namespace     ::com::sun::star::container;
@@ -504,29 +506,71 @@ void SAL_CALL SvtFilePicker::setTitle( const OUString& _rTitle ) throw (RuntimeE
 sal_Int16 SAL_CALL SvtFilePicker::execute(  ) throw (RuntimeException, std::exception)
-    return OCommonPicker::execute();
-// XAsynchronousExecutableDialog functions
-void SAL_CALL SvtFilePicker::setDialogTitle( const OUString& _rTitle ) throw (RuntimeException, std::exception)
-    setTitle( _rTitle );
-void SAL_CALL SvtFilePicker::startExecuteModal( const Reference< ::com::sun::star::ui::dialogs::XDialogClosedListener >& xListener )
-    throw (RuntimeException,
-           std::exception)
-    m_xDlgClosedListener = xListener;
-    prepareDialog();
-    prepareExecute();
-    getDialog()->EnableAutocompletion( true );
-    getDialog()->StartExecuteModal( LINK( this, SvtFilePicker, DialogClosedHdl ) );
+    GError * err = nullptr;
+    GDBusProxy * proxy = g_dbus_proxy_new_for_bus_sync(
+        "org.freedesktop.portal.ContentPortal",
+        "/org/freedesktop/portal/content",
+        "org.freedesktop.portal.ContentPortal", nullptr, &err);
+    if (proxy == nullptr) {
+        assert(err != nullptr);
+        SAL_DEBUG("GError " << g_quark_to_string(err->domain) << " " << err->code << " " << err->message);
+        g_clear_error(&err);
+        std::abort();
+    }
+    assert(err == nullptr);
+    GVariant * ret = g_dbus_proxy_call_sync(
+        proxy, "Open", g_variant_new("(as)", nullptr), G_DBUS_CALL_FLAGS_NONE,
+        G_MAXINT, nullptr, &err);
+    bool cncl = false;
+    OUString id;
+    if (ret == nullptr) {
+        assert(err != nullptr);
+        cncl = g_error_matches(err, g_io_error_quark(), G_IO_ERROR_DBUS_ERROR);
+        if (!cncl) {
+            SAL_DEBUG("GError " << g_quark_to_string(err->domain) << " " << err->code << " " << err->message);
+            std::abort();
+        }
+        g_clear_error(&err);
+    } else {
+        //TODO type check
+        GVariant * v = g_variant_get_child_value(ret, 0);
+        gsize len;
+#if 0
+        gchar const * s = g_variant_get_string(v, &len);
+        gconstpointer p = g_variant_get_fixed_array(v, &len, 1);
+        char const * s = static_cast<char const *>(p);
+        if (s == nullptr) {
+            SAL_DEBUG("nullptr");
+            std::abort();
+        }
+        if (!rtl_convertStringToUString(
+                &id.pData, s, len,
+                RTL_TEXTENCODING_UTF8,
+        {
+            SAL_DEBUG("not UTF-8");
+            std::abort();
+        }
+        g_variant_unref(v);
+        g_variant_unref(ret);
+    }
+    g_object_unref(proxy);
+    SAL_DEBUG("CHOSE "<<int(!cncl)<<" <"<<id<<">");
+    if (cncl) {
+        return RET_CANCEL;
+    } else {
+#if 0
+        URL_ = "document:" + id;
+        URL_ = "file://" + id;
+        return RET_OK;
+    }
@@ -588,6 +632,10 @@ OUString SAL_CALL SvtFilePicker::getDisplayDirectory() throw( RuntimeException,
 Sequence< OUString > SAL_CALL SvtFilePicker::getFiles() throw( RuntimeException, std::exception )
+if(true) {
+    SAL_DEBUG("getFiles <"<<URL_<<">");
+    return {URL_};
     SolarMutexGuard aGuard;
diff --git a/fpicker/source/office/OfficeFilePicker.hxx b/fpicker/source/office/OfficeFilePicker.hxx
index fa8313e..685e40c 100644
--- a/fpicker/source/office/OfficeFilePicker.hxx
+++ b/fpicker/source/office/OfficeFilePicker.hxx
@@ -19,7 +19,7 @@
-#include <cppuhelper/implbase5.hxx>
+#include <cppuhelper/implbase4.hxx>
 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
 #include <com/sun/star/ui/dialogs/XFilePreview.hpp>
 #include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
@@ -50,11 +50,10 @@ typedef ::com::sun::star::uno::Sequence< OUString >  OUStringList;   // can be t
 // class SvtFilePicker ---------------------------------------------------
-typedef ::cppu::ImplHelper5 <   ::com::sun::star::ui::dialogs::XFilePicker3
+typedef ::cppu::ImplHelper4 <   ::com::sun::star::ui::dialogs::XFilePicker3
                             ,   ::com::sun::star::ui::dialogs::XFilePickerControlAccess
                             ,   ::com::sun::star::ui::dialogs::XFilePreview
                             ,   ::com::sun::star::lang::XServiceInfo
-                            ,   ::com::sun::star::ui::dialogs::XAsynchronousExecutableDialog
                             >   SvtFilePicker_Base;
 class SvtFilePicker :public SvtFilePicker_Base
@@ -103,14 +102,6 @@ public:
     virtual sal_Int16 SAL_CALL execute(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-    // XAsynchronousExecutableDialog functions
-    virtual void SAL_CALL setDialogTitle( const OUString& _rTitle ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-    virtual void SAL_CALL startExecuteModal( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XDialogClosedListener >& xListener )
-        throw (::com::sun::star::uno::RuntimeException,
-               std::exception) SAL_OVERRIDE;
     // XFilePicker functions
@@ -224,6 +215,8 @@ private:
     void                prepareExecute( );
     DECL_LINK(          DialogClosedHdl, Dialog* );
+    OUString URL_;

which on the one hand works around the xml-config problem I mention in the presentation and on the other hand hacks in some initial demo support for the document portal.

The latter works by replacing the LibreOffice-internal file picker (“Tools – Options… – LibreOffcie – General – Open/Save Dialogs – Use LibreOffice dialogs”) with the xdg-content-choser (you need the latest git revision of the chooser, along with the latest git revision of xdg-app for that to work). Once you select the LibreOffice-internal file picker, you can open a document from outside the sandbox, read-only for now. Read-write and saving back is next on the agenda…


In C++, two types that have the same (fully qualified) name must be the same. The One Definition Rule (ODR) is there to ensure that, even if the types appear in different compilation units. C++ implementations are not required to diagnose all ODR violations, but they could be observed when features relying on runtime type information (exception handling, dynamic_cast, -fsanitize=vptr, …) start to misbehave.

What the C++ standard does not cover is how to pick unique names (by picking unique namespaces). That prevents composability. If you have two C++ libraries whose source code you cannot change, you cannot in general link them into the same program, as that might cause ODR violations.

What the C++ standard does not cover either is dynamic libraries and symbol visibility across such libraries. That lead C++ implementations to slightly bend the ODR rules in order to mitigate the above problem: If two different types that happen to have the same fully qualified name are hidden in two different dyanmic libraries, that is technically still an ODR violation, but no problems can arise from it. (In theory, it might also be possible for each library to place all its “internal” entities into unnamed namespaces, which would solve the same problems. In practice, however, a library’s developers will most likely want to spread it across multiple compilation units and still use such internal entities across compilation units, where unnamed namespaces would no longer work.)

A key aspect of the above is how to hide a type in a dynamic library. RTTI for a type is typically represented in C++ implementations as a set of symbols, one of them denoting a C-style string representation of the (mangled) type name. Then, if a C++ implementation uses comparison of string addresses (and not of string contents) to determine type equality, and if the RTTI string symbols are not coalesced across dynamic libraries at runtime (e.g., by keeping them non-exported), then hiding works.

And, on the other hand, an important corollary of the above is that if uses of a type across multiple dynamic objects shall be considered equal (so that e.g. an instance of that type can be thrown in one dynamic library and caught in another), the corresponding RTTI string symbols do need to be coalesced at runtime (e.g., by exporting them as weak symbols from all the dynamic objects using them).

That is why the Itanium C++ ABI mandates address comparison of RTTI strings. It is not only faster (to do the comparison, at least; though not necessarily to load the dynamic libraries and resolve the weak symbols for those types that shall be considered equal across dynamic libraries), it also enables composability.

However, a third thing the C++ standard does not cover is dynamic loading of (dynamic) libraries, with mechanisms like POSIX dlopen. An invocation of dlopen can be either RTLD_LOCAL or RTLD_GLOBAL. While RTLD_GLOBAL makes the exported symbols of the loaded library available to subsequently loaded libraries (which is important if there is any types that shall be considered equal across those libraries, see above), RTLD_LOCAL does not—and can thus break things like throwing exceptions across libraries.

The RTLD_LOCAL problem caused GCC maintainers to deviate from the Itanium C++ ABI and compare RTTI string symbols by content rather than by address. That implies breaking composability.

Clang still sticks to the Itanium C++ ABI’s by-address comparison, but that difference between GCC and Clang does not normally make a difference on Linux: Things like exception handling and dynamic_cast are handled by the C++ runtime library, and on Linux that is GCC’s libstdc++ regardless whether you compile wih GCC or Clang.

One case where it does make a difference is -fsanitize=function and -fsanitize=vptr, UBSan checks detecting certain undefined behavior involving function pointers or polymorphic object types, respectively. For Clang, the RTTI comparisons internally done by those checks are hard-coded in the compiler and would not call into libstdc++. So, when using -fsanitize=undefined: