https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120607
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |xry111 at gcc dot gnu.org
--- Comment #4 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Yan from comment #2)
> thanks, I didn't notice this was always true.
To be noted, it's **not** related to if this is **always** true. Even if you
change it to
void test_builtin_unreachable() {
int bb;
scanf("%d", &bb);
if ((bb & ~3) != 0)
__builtin_unreachable();
if ((bb & 1) == 0)
__builtin_unreachable();
if (bb == 2)
printf("the value of bb is: %d\n", bb);
}
at -O2 it will still print nothing when you input 2. The behavior of the
program is simply undefined once __builtin_unreachable is called in an
execution.