Skip to content

discarded-reloc of copy-only class #15

Description

@ecatmur

If a class was written before C++11 and thus has a copy constructor but no move constructor, then a discarded reloc may have precisely the wrong effect, constructing and destroying a temporary with overhead and no effect on the source object. This may sound unlikely, but in industry it's not unusual to have to work with vendor code that was written a very long time ago or has to target ancient compilers as well as modern ones.

I think it might be necessary to make discarded-reloc ill-formed if the source object is a function parameter and the constructor selected for relocation would be a copy constructor. Either that or call it out with a strong hint that implementations should issue a warning, but we may as well get this right to start with.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions