GCC Bugzilla – Attachment 30980 Details for
Bug 53001
-Wfloat-conversion should be available to warn about floating point errors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to fixup gcc float conversions in GCC
fixup_float_conversions.diff (text/plain), 5.12 KB, created by
Joshua Cogliati
on 2013-10-11 02:31:53 UTC
(
hide
)
Description:
Patch to fixup gcc float conversions in GCC
Filename:
MIME Type:
Creator:
Joshua Cogliati
Created:
2013-10-11 02:31:53 UTC
Size:
5.12 KB
patch
obsolete
>Index: gcc/c-family/c-cppbuiltin.c >=================================================================== >--- gcc/c-family/c-cppbuiltin.c (revision 203112) >+++ gcc/c-family/c-cppbuiltin.c (working copy) >@@ -157,7 +157,7 @@ builtin_define_float_constants (const ch > p log10 b if b is a power of 10 > floor((p - 1) log10 b) otherwise > */ >- dig = (fmt->p - 1) * log10_b; >+ dig = (int)((fmt->p - 1) * log10_b); > sprintf (name, "__%s_DIG__", name_prefix); > builtin_define_with_int_value (name, dig); > >@@ -173,7 +173,7 @@ builtin_define_float_constants (const ch > > Recall that emin is negative, so the integer truncation calculates > the ceiling, not the floor, in this case. */ >- min_10_exp = (fmt->emin - 1) * log10_b; >+ min_10_exp = (int)((fmt->emin - 1) * log10_b); > sprintf (name, "__%s_MIN_10_EXP__", name_prefix); > sprintf (buf, "(%d)", min_10_exp); > builtin_define_with_value (name, buf, 0); >@@ -208,7 +208,7 @@ builtin_define_float_constants (const ch > Hand-waving aside, crunching all of the sets of constants above by hand > does not yield a case for which the first term is significant, which > in the end is all that matters. */ >- max_10_exp = fmt->emax * log10_b; >+ max_10_exp = (int)(fmt->emax * log10_b); > sprintf (name, "__%s_MAX_10_EXP__", name_prefix); > builtin_define_with_int_value (name, max_10_exp); > >@@ -224,14 +224,14 @@ builtin_define_float_constants (const ch > { > double d_decimal_dig > = 1 + (fmt->p < ldfmt->p ? ldfmt->p : fmt->p) * log10_b; >- decimal_dig = d_decimal_dig; >+ decimal_dig = (int)d_decimal_dig; > if (decimal_dig < d_decimal_dig) > decimal_dig++; > } > /* Similar, for this type rather than long double. */ > { > double type_d_decimal_dig = 1 + fmt->p * log10_b; >- type_decimal_dig = type_d_decimal_dig; >+ type_decimal_dig = (int)type_d_decimal_dig; > if (type_decimal_dig < type_d_decimal_dig) > type_decimal_dig++; > } >Index: gcc/mcf.c >=================================================================== >--- gcc/mcf.c (revision 203112) >+++ gcc/mcf.c (working copy) >@@ -348,8 +348,8 @@ mcf_sqrt (double x) > > gcc_assert (x >= 0); > >- convertor.floatPart = x; >- convertor2.floatPart = x; >+ convertor.floatPart = (float)x; >+ convertor2.floatPart = (float)x; > convertor.intPart = MAGIC_CONST1 + (convertor.intPart >> 1); > convertor2.intPart = MAGIC_CONST2 - (convertor2.intPart >> 1); > >Index: gcc/predict.c >=================================================================== >--- gcc/predict.c (revision 203112) >+++ gcc/predict.c (working copy) >@@ -792,7 +792,7 @@ combine_predictions_for_insn (rtx insn, > /* If one probability is 0% and one 100%, avoid division by zero. */ > combined_probability = REG_BR_PROB_BASE / 2; > else >- combined_probability = (((double) combined_probability) * probability >+ combined_probability = (int)(((double) combined_probability) * probability > * REG_BR_PROB_BASE / d + 0.5); > } > >@@ -957,7 +957,7 @@ combine_predictions_for_bb (basic_block > /* If one probability is 0% and one 100%, avoid division by zero. */ > combined_probability = REG_BR_PROB_BASE / 2; > else >- combined_probability = (((double) combined_probability) >+ combined_probability = (int)(((double) combined_probability) > * probability > * REG_BR_PROB_BASE / d + 0.5); > } >Index: gcc/real.c >=================================================================== >--- gcc/real.c (revision 203112) >+++ gcc/real.c (working copy) >@@ -1550,14 +1550,14 @@ real_to_decimal_for_mode (char *str, con > } > > /* Bound the number of digits printed by the size of the representation. */ >- max_digits = SIGNIFICAND_BITS * M_LOG10_2; >+ max_digits = (int)(SIGNIFICAND_BITS * M_LOG10_2); > if (digits == 0 || digits > max_digits) > digits = max_digits; > > /* Estimate the decimal exponent, and compute the length of the string it > will print as. Be conservative and add one to account for possible > overflow or rounding error. */ >- dec_exp = REAL_EXP (&r) * M_LOG10_2; >+ dec_exp = (int)(REAL_EXP (&r) * M_LOG10_2); > for (max_digits = 1; dec_exp ; max_digits++) > dec_exp /= 10; > >@@ -2215,7 +2215,7 @@ decimal_integer_string (char *str, const > sign = r.sign; > r.sign = 0; > >- dec_exp = REAL_EXP (&r) * M_LOG10_2; >+ dec_exp = (int)(REAL_EXP (&r) * M_LOG10_2); > digits = dec_exp + 1; > gcc_assert ((digits + 2) < (int)buf_size); > >@@ -2818,7 +2818,7 @@ significand_size (enum machine_mode mode > than the number of bits required to hold the largest coefficient > of this mode. */ > double log2_10 = 3.3219281; >- return fmt->p * log2_10; >+ return (int)(fmt->p * log2_10); > } > return fmt->p; > } >Index: libcpp/symtab.c >=================================================================== >--- libcpp/symtab.c (revision 203112) >+++ libcpp/symtab.c (working copy) >@@ -287,7 +287,8 @@ ht_dump_statistics (cpp_hash_table *tabl > : (x) / (1024*1024)))) > #define LABEL(x) ((x) < 1024*10 ? ' ' : ((x) < 1024*1024*10 ? 'k' : 'M')) > >- total_bytes = longest = sum_of_squares = nids = 0; >+ total_bytes = longest = nids = 0; >+ sum_of_squares = 0.0; > p = table->entries; > limit = p + table->nslots; > do
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 53001
:
30870
|
30871
|
30873
|
30882
|
30899
|
30913
|
30937
|
30979
| 30980 |
30994
|
31014
|
31065
|
31097