https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119222
--- Comment #12 from Gwen Fu <gwen3293940943 at gmail dot com> ---
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 double
here is the curcial part about this bugu of conversion_warning:
static bool
conversion_warning (location_t loc, tree type, tree expr, tree result)
{
// type -> int , expr->1.0/0.0 result->(int)1.0/0.0
.....
switch (TREE_CODE (expr))
{
case EQ_EXPR:
case NE_EXPR:
case LE_EXPR:
case GE_EXPR:
.....
case REAL_CST:
case INTEGER_CST:
.....
}
return false ;
}
And
warning_for_convert_and_check only responsible for the two situations below :
if (TREE_CODE (expr) == INTEGER_CST
&& (TREE_CODE (type) == INTEGER_TYPE
|| TREE_CODE (type) == BITINT_TYPE
|| (TREE_CODE (type) == ENUMERAL_TYPE
&& TREE_CODE (ENUM_UNDERLYING_TYPE (type)) != BOOLEAN_TYPE))
&& !int_fits_type_p (expr, type))
{....}
else if ((TREE_CODE (result) == INTEGER_CST
|| TREE_CODE (result) == FIXED_CST) && TREE_OVERFLOW (result))
{.....}
The rest of the situation is all handed over to the top function。
If you need more testimonies , I will give you !!!!!