C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::typeid_except ( Paper Attached )

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sun, 03 Mar 2024 11:48:27 -0800
On Sunday, 3 March 2024 08:37:33 PST Tiago Freire via Std-Proposals wrote:
> Throwing exceptions across dll boundaries has been widely accepted as
> ill-formed, partly because there's no known form of RTTI that is capable of
> working correctly in all situation across such boundaries

In reality, those work just fine, just as dynamic_cast does, provided you
comply with one of these two scenarios:

1) the runtime links all DLLs as a global namespace and everything is
exported. This is the default on Unix systems, actually, but is impossible on
Windows. It's also considered bad practice to export everything and the
kitchen sink on Unix systems.

2) each thrown type or dynamic_cast type is well-anchored in a single TU and
and exported from a single DLL, with no weak virtual tables. That means it
must have at least one non-inline virtual method. That in turn forbids header-
only exception types: you MUST have a .cpp. This is the recommended practice
for every single polymorphic type, actually.

The standard only recognises case #1 because it doesn't understand what a
library is. That means the standards-compliant way of doing things is
considered bad practice.

I argued a month or two ago that the Standard should begin to learn what a
library is so we can hopefully make it part of the Standard (with capital S)
the standard and correct way of doing things.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2024-03-03 19:48:42