Date: Thu, 12 Jan 2023 16:34:28 +0100
On 2023-01-12 at 11:23, Frederick Virchanza Gotham via Std-Proposals
wrote:
>
>Now if you were to ask me . . . . I would almost go so far as to
>propose that C++26 should deprecate defining a global object that
>doesn't satisfy 'is_trivial' so that all such objects would be wrapped
>in an std::optional<T> and emplaced within the body of 'main', but of
>course I know that I won't get any support on that.
It would also not cover most use-cases, for example
wrote:
>
>Now if you were to ask me . . . . I would almost go so far as to
>propose that C++26 should deprecate defining a global object that
>doesn't satisfy 'is_trivial' so that all such objects would be wrapped
>in an std::optional<T> and emplaced within the body of 'main', but of
>course I know that I won't get any support on that.
It would also not cover most use-cases, for example
----
/* const */ int i = function_that_throws();
int main(){
}
----
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)
Federico
Received on 2023-01-12 15:34:38
