Skip to content

Demand for copy constructor definition when mandatory copy elision must take place #53245

Closed as not planned
@Fedr

Description

In next code copy constructor shall not be called and checked because of mandatory copy elision:

struct A {       
    consteval A() {}
    consteval A(const A&);
    consteval void f() {}
};

int main() {
    A{A{}}.f();
}

GCC and MSVC accept the code. But Clang does not:

undefined constructor 'A' cannot be used in a constant expression

Demo: https://gcc.godbolt.org/z/cKboT3qf6

Activity

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

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"constevalC++20 constevalduplicateResolved as duplicate

    Type

    No type

    Projects

    • Status

      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions