Skip to content

Statement attribute on a case label suppresses 'bypassing variable initialization' error #84072

@dwblaikie

Description

@dwblaikie

https://godbolt.org/z/j4b69q1dq

void Func(int x) {
    switch (x) {
        [[likely]] case 0:
        case 1:
            int i = 3;
        case 2:
            break;
    }
    switch (x) {
        case 0:
        case 1:
            int i = 3;
        case 2:
            break;
    }
}
<source>:14:9: error: cannot jump from switch statement to this case label
   14 |         case 2:
      |         ^
<source>:13:17: note: jump bypasses variable initialization
   13 |             int i = 3;
      |              

Metadata

Metadata

Assignees

Labels

accepts-invalidclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzergood first issuehttps://github.com/llvm/llvm-project/contribute

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions