[llvm-bugs] [Bug 52251] New: Invalid consteval constructor invocation does not cause an error

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 21 05:47:33 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=52251

            Bug ID: 52251
           Summary: Invalid consteval constructor invocation does not
                    cause an error
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: stephan.bergmann.secondary at googlemail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

At least with Clang 13 and recent Clang 14 trunk,

> $ cat test.cc 
> struct S {
>     consteval S() {}
>     int a;
> };
> S s2;

> $ clang++ -std=c++20 -fsyntax-only test.cc

erroneously succeeds, while e.g. with GCC 11 it fails with

> $ g++ -std=c++20 -fsyntax-only test.cc
> test.cc:5:3: error: ‘S()’ is not a constant expression
>     5 | S s2;
>       |   ^~
> test.cc:5:3: error: ‘s2.S::S()’ is not a constant expression because it refers to an incompletely initialized variable

(I think this is different from bug 51560, as the initialization of s2 here
asks for default-initialization via the S() constructor.)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211021/951c6564/attachment.html>


More information about the llvm-bugs mailing list