Skip to content

[basic.life] It might be misleading to mention non-trivial destructor #717

Open
@frederick-vs-ja

Description

@frederick-vs-ja

Full name of submitter (unless configured in github; will be published with the issue): Jiang An

Reference (section label): [basic.life]

Link to reflector thread (if any):

Issue description:

Currently, [basic.life] p11 says non-trivial destructor, which might be misleading, because such UB can happen even when the destructor is trivial. It seems that such UB (calling non-static member function for an out-of-lifetime object) is already specified in p7 and/or p8, and thus p11 seems completely redundant.

cplusplus/draft#6389 attempted to resolve this but it was rejected.

Suggested resolution:

Modify [basic.life] p11 as indicated (turn it into a note, and remove mentioning of triviality):

  1. [Note ?: If a program ends the lifetime of an object of type T with static ([basic.stc.static]), thread ([basic.stc.thread]), or automatic ([basic.stc.auto]) storage duration and if T has a non-trivial destructor for which destructor will be called implicitly, [...] [Example 4: [...] — end example] end note]

This might be added to CWG3022.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions