[llvm-bugs] [Bug 49454] New: C++20 `[[likely]]`/`[[unlikely]]` `case` statements erroneously fail to compile in the presence of `[[fallthrough]]`

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Mar 5 09:13:19 PST 2021


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

            Bug ID: 49454
           Summary: C++20 `[[likely]]`/`[[unlikely]]` `case` statements
                    erroneously fail to compile in the presence of
                    `[[fallthrough]]`
           Product: new-bugs
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: ian at geometrian.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

See the following complete example:

    //Compile with "-std=c++20"
    void f(int i) {
        switch (i) {
                [[likely]] case 1:
                        [[fallthrough]];
                case 2:
                        break;
        }
    }

This should compile (and does on every other compiler), but doesn't on Clang. 
Clang (tested 13.0.0) produces:

    <source>:5:13: error: fallthrough annotation does not directly precede
switch label
                [[fallthrough]];
                ^

Removing either `[[likely]]` or `[[fallthrough]];` is sufficient to cause the
compile to succeed.

-- 
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/20210305/de48209e/attachment.html>


More information about the llvm-bugs mailing list