#1152860 g++ switch/case epic bug

Package:
g++
Source:
g++
Description:
GNU C++ compiler
Submitter:
Ivan Beliew
Date:
2026-11-02 14:01:02 UTC
Severity:
normal
#1152860#5
Date:
2026-11-02 12:59:12 UTC
From:
To:
#include <iostream>
enum class key {A, B};
void test(key k)
{
switch (k)
{
case key::A:
std::cerr << "A\n";
break;
deafult: // HERE!!!
std::cerr << "DFL\n";
break;
}
}
int main(int argc, char* argv[])
{
test(key::A);
test(key::B);
}

but it does:

xxx$ g++ -pedantic -o run run.cpp
xxx$ ./run
A
xxx$

I am using Debian GNU/Linux 13 (trixie), kernel 6.12.113-1 x86_64. Best regards.

#1152860#14
Date:
2026-11-02 13:59:01 UTC
From:
To:
Although I agree you've misspelled "default", this is nevertheless legal
because it looks just like a label, and you're allowed to have a label
named "deafult".