[Bug c++/105563] New: Consteval copy-constructor is allowed in not-constant expression

fchelnokov at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed May 11 11:17:07 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105563

            Bug ID: 105563
           Summary: Consteval copy-constructor is allowed in not-constant
                    expression
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

In the following program, struct A has `consteval` copy-constructor, which is 
invoked in main() run-time via A{a1}:

struct A {
    int i = 0;
    A() {}
    consteval A(const A&) = default;
};

int main() {
    A a1;
    A{a1};
}

Both Clang and MSVC reject this program, but not GCC. Demo:
https://gcc.godbolt.org/z/4G7ndne35


More information about the Gcc-bugs mailing list