https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93674
--- Comment #6 from Gábor Buella <gbuella at gmail dot com> --- (In reply to Jonathan Wakely from comment #4) > I can't reproduce this with GCC 9, only 8. $ cat code.cc enum some_enum { x = 1000 }; void sink(some_enum); void func() { for (int i = 0; i < 3; ++i) { int j = 3; while (j >= 0) { // turned into an uncoditional jmp by GCC // Note: (i + j) is always non-negative here // Actually, (i + j) is always of the values // given when defining the type above. sink((some_enum)(i + j)); --j; } } } $ g++-9 -Wall -Wextra -pedantic -std=c++14 code.cc -fstrict-enums -S -o /dev/stdout -fno-dwarf2-cfi-asm -O3 | head -20 .file "code.cc" .text .p2align 4 .globl _Z4funcv .type _Z4funcv, @function _Z4funcv: .LFB0: endbr64 pushq %rbx .LCFI0: movl $3, %ebx .p2align 4,,10 .p2align 3 .L2: movl %ebx, %edi subl $1, %ebx call _Z4sink9some_enum@PLT jmp .L2 .LFE0: .size _Z4funcv, .-_Z4funcv $ g++-9 --version g++-9 (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.