C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Catch exception thrown from constructor of global object

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 12 Jan 2023 10:57:10 -0800
On Thursday, 12 January 2023 07:34:28 PST Federico Kircheis via Std-Proposals
wrote:
> Also std::optional as global variable is problematic if inside a
> library, depending on the visibility of the symbols, the destructor
> might be executed more than once (and thus be UB)

In other words, it should be exactly as you've intended and coded.

A globally-visible symbol should register its destructor exactly once. A
locally-visible ("hidden") symbol should register its destructor exactly once
in each library it is used.

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

Received on 2023-01-12 18:57:11