@xdot the deafult for gcc is -O0 try agin with -O3, Just double checked. Its not undefined behaviour, but `(eBlockFace) 10000` has an unspecified value. Which means that the compiler is allowed to pretend that casting to the enum will always result in a valid value no mater what you cast during optimization passes. SO for your example clang can reason that is is allowed to round 10000 to 0 due to it being outside the specified range.
@xdot We can still apply a simple range check. Also it appears that having a value inside the range is valid even if it doesn't match  an enum key. However even if the values inside the range are valid the printf is still unreachable because the blockface enum has no gaps.