[Bug c++/119222] Conversion of inf to integer is not diagnosed

2025-03-26 Thread gwen3293940943 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119222 --- Comment #17 from Gwen Fu --- Created attachment 60895 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60895&action=edit Other cases of this conversion, including assignment and some other use cases Initialization and assignment

[Bug c++/119222] Conversion of inf to integer is not diagnosed

2025-03-24 Thread gwen3293940943 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119222 --- Comment #16 from Gwen Fu --- I am void under the gcc/c-family/c-warn.cc file warnings_for_convert_and_check (location_t loc, tree type, tree expr, tree result) function performs the following judgment and processing: /*"inifity to int" thi

[Bug c++/119222] Conversion of inf to integer is not diagnosed

2025-03-18 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119222 --- Comment #15 from Jonathan Wakely --- (In reply to Gwen Fu from comment #13) >warning_at(loc, OPT_Wfloat_conversion, > "conversion from %qT to %qT changes infinity to maximum or minimum integer > value", expr_type , type) ; The mess

[Bug c++/119222] Conversion of inf to integer is not diagnosed

2025-03-17 Thread gwen3293940943 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119222 --- Comment #14 from Gwen Fu --- and I will send the patch at the same time

[Bug c++/119222] Conversion of inf to integer is not diagnosed

2025-03-17 Thread gwen3293940943 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119222 --- Comment #13 from Gwen Fu --- When executing the conversion_warning function, if you do not add any of the three compilation options -Warn-conversion or -Warn_sign_conversion or -Warn-float-conversion, the function will return directly.

[Bug c++/119222] Conversion of inf to integer is not diagnosed

2025-03-16 Thread gwen3293940943 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119222 --- Comment #12 from Gwen Fu --- I know how this bug generate this time (100%)! This is because the funx conversion_warning (in c-family/c-warn.cc , the helper function for warnings_for_convert_and_check)lacks some checks when expr is of type do

[Bug c++/119222] Conversion of inf to integer is not diagnosed

2025-03-15 Thread gwen3293940943 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119222 --- Comment #11 from Gwen Fu --- E , This is a bit complicated. But I think the problem must occur in the grammatical analysis or semantic analysis stage I would like to know in which file should the code for floating point (real number) typ

[Bug c++/119222] Conversion of inf to integer is not diagnosed

2025-03-15 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119222 --- Comment #10 from Jonathan Wakely --- Because you didn't compile with -fsanitize=float-cast-overflow If you use that option, then SANITIZE_FLOAT_CAST will be set. But that is about adding instrumentation to give runtime diagnostics. This bu

[Bug c++/119222] Conversion of inf to integer is not diagnosed

2025-03-15 Thread gwen3293940943 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119222 --- Comment #9 from Gwen Fu --- I am sorry for my recklessness and carelessness! And thank you for your patient guidance. In gcc/convert.cc : func:convert_to_integer_1 : the case : case REAL_TYPE: if (sanitize_flags_p (SANITIZE_FLOAT_

[Bug c++/119222] Conversion of inf to integer is not diagnosed

2025-03-15 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119222 --- Comment #8 from Jonathan Wakely --- ... as I already tried to explain in comment 4.

[Bug c++/119222] Conversion of inf to integer is not diagnosed

2025-03-15 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119222 --- Comment #7 from Andrew Pinski --- 1.0/0.0 is well defined with IEEE floating point to be defined as infinite. Warning about that is not right. What this bug is asking for is the warning converting infinite or NaN to an integral type

[Bug c++/119222] Conversion of inf to integer is not diagnosed

2025-03-15 Thread gwen3293940943 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119222 --- Comment #6 from Gwen Fu --- And also see "constexpr.cc in "gcc/cp": the function "potential_constant_expression_1": if (integer_zerop (denom)) { if (flags & tf_error) constexpr_error (input_locatio

[Bug c++/119222] Conversion of inf to integer is not diagnosed

2025-03-14 Thread gwen3293940943 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119222 --- Comment #5 from Gwen Fu --- Maybe the bug is related to the code below: (in gcc/fold-const.cc :fold_binary_loc) case RDIV_EXPR: /* Don't touch a floating-point divide by zero unless the mode of the constant can represent i

[Bug c++/119222] Conversion of inf to integer is not diagnosed

2025-03-12 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119222 --- Comment #4 from Jonathan Wakely --- That's a completely different example though. The bug is about conversion from double to int. 1/0 does not involve any floating-point types, it's just an undefined integer division. 1/static_cast(0) is n

[Bug c++/119222] Conversion of inf to integer is not diagnosed

2025-03-12 Thread gwen3293940943 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119222 --- Comment #3 from Gwen Fu --- (In reply to Antony Polukhin from comment #0) > Consider the following example: > > int foo() { > return 1 / static_cast(0); > } > > > With -Wall -Wextra there is no warning about an undefined behavior > ([

[Bug c++/119222] Conversion of inf to integer is not diagnosed

2025-03-12 Thread gwen3293940943 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119222 Gwen Fu changed: What|Removed |Added CC||gwen3293940943 at gmail dot com --- Comment #

[Bug c++/119222] Conversion of inf to integer is not diagnosed

2025-03-11 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119222 Jonathan Wakely changed: What|Removed |Added Status|UNCONFIRMED |NEW Ever confirmed|0