https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119222
--- Comment #3 from Gwen Fu <gwen3293940943 at gmail dot com> --- (In reply to Antony Polukhin from comment #0) > Consider the following example: > > int foo() { > return 1 / static_cast<double>(0); > } > > > With -Wall -Wextra there is no warning about an undefined behavior > ([conv.fpint] p1 "The behavior is undefined if the truncated value cannot be > represented in the destination type.") > > Please add a warning > > Godbolt playground: https://godbolt.org/z/cMYo6xPaY I tried this example : int foo() { return 1 / 0; } int main() { return 0; } There is a warning : 119222.cc: In function ‘int foo()’: 119222.cc:2:14: warning: 被零除(divide by zero)[-Wdiv-by-zero] 2 | return 1 / 0; | ~~^~~