[Bug middle-end/78977] [7 Regression] g++7 snprintf() of double produces wrong code with -O3

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jan 5 16:44:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78977

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Actually, diffing the pr78977.ii.173t.printf-return-value2 file between r244036
and r244037, I see:
--- pr78977.ii.173t.printf-return-value2.r244036       2017-01-05
11:37:32.000000000 -0500
+++ pr78977.ii.173t.printf-return-value2.r244037       2017-01-05
11:38:39.000000000 -0500
@@ -16052,7 +16052,7 @@ seqan::String<TValue, seqan::Alloc<TSpec
 ;; Function void SEQAN_TEST_test_random_beta_write() [with bool
speed_up_dummy_to_prevent_compilation_of_unused_tests_ = true]
(_Z33SEQAN_TEST_test_random_beta_writeILb1EEvv, funcdef_no=12273,
decl_uid=209665, cgraph_uid=3269, symbol_order=3339)

 On line 1161 substituting 3 for snprintf return value (output constant).
-On line 1161 substituting 8 for snprintf return value (output constant).
+On line 1161 snprintf in-bounds return value in range [3, 8].
 void SEQAN_TEST_test_random_beta_write() [with bool
speed_up_dummy_to_prevent_compilation_of_unused_tests_ = true] ()
 {
   vector(2) long unsigned int * vectp.1377;
@@ -17367,10 +17367,10 @@ void SEQAN_TEST_test_random_beta_write()

   <bb 100> [8.37%]:
   ochunk ={v} {CLOBBER};
+  # RANGE [3, 8] NONZERO 15
   # USE = nonlocal null { D.27886 D.32751 D.46937 D.47309 D.221966 D.221967
D.221968 D.250264 D.250270 D.250273 D.250285 D.250300 D.250306 D.250309
D.250333 D.250339 D.250342 D.250354 D.250369 D.250375 D.250378 D.250402
D.250408 D.250411 D.250426 D.250427 D.250432 D.250445 D.250663 } (nonlocal,
escaped, escaped heap, interposable)
   # CLB = nonlocal null { D.27886 D.32751 D.46937 D.47309 D.221966 D.221967
D.221968 D.250264 D.250270 D.250273 D.250285 D.250300 D.250306 D.250309
D.250333 D.250339 D.250342 D.250354 D.250369 D.250375 D.250378 D.250402
D.250408 D.250411 D.250426 D.250427 D.250432 D.250445 D.250663 } (nonlocal,
escaped, escaped heap, interposable)
-  snprintf (&buffer, 32, "%g",
2.99999999999999988897769753748434595763683319091796875e-1);
-  _355 = 8;
+  _355 = snprintf (&buffer, 32, "%g",
2.99999999999999988897769753748434595763683319091796875e-1);
   # RANGE ~[2147483648, 18446744071562067967]
   len_356 = (size_t) _355;
   MEM[(struct  &)&ochunk] ={v} {CLOBBER};

So that looks like r244037 has fixed this bug.  Please reopen if that is not
the case.  Given Martin's description that
2.99999999999999988897769753748434595763683319091796875e-1 could be printed
with %g as
0.299999 or as 0.3 depending on rounding, assuming range [3, 8] is reasonable,
hardcoding return value of 8 is obviously wrong.


More information about the Gcc-bugs mailing list