Exploiting undefined behavior is something compilers can and will do; that's not a bug. (Specifically, if a compiler can choose to omit code where it can prove that going down that branch would lead to undefined behavior. That's not what happened here.)
That's still a compiler bug.
But yes, this is a bug in GCC and the title should show that.