Skip to content

[meta.rel] is_­nothrow_­convertible does not clearly require nothrow destruction LWG 3400, LWG 2116 #3576

Open
@frederick-vs-ja

Description

@frederick-vs-ja

By @Dani-Hub , is_nothrow_convertible considers destruction of the converted object (if To is an object type) or the temporary (if To is a reference type and the temporary to bind would be created) by design. And known implementations (msvc, libc++, libstdc++) behave correctly.

For example, given a type Weird defined as

struct Weird {
  Weird(int) noexcept {}
  ~Weird() noexcept(false) {}
};

Then std::is_nothrow_convertible_v<int, Weird> is false.

However, I suspect that wording in [meta.rel]/5 only requires the well-formedness, and whether the destruction after the initialization of To is considered as part of the conversion is not mentioned.
So "the conversion, as defined by is_­convertible" in the specification of is_nothrow_convertible might not be precisely defined, and may lead to unintended comprehension, e.g. std::is_nothrow_convertible_v<int, Weird> can be true since the converting constructor itself is noexcept, although destruction of Weird is not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lwgIssue must be reviewed by LWG.not-editorialIssue is not deemed editorial; the editorial issue is kept open for tracking.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions