Bug 77683 - [7 regression] ICE on %lf directive in format_floating in gimple-ssa-sprintf.c:1163
Summary: [7 regression] ICE on %lf directive in format_floating in gimple-ssa-sprintf....
Status: VERIFIED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: 7.0
Assignee: Martin Sebor
URL:
Keywords: ice-on-valid-code
: 77740 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-09-21 20:24 UTC by Martin Sebor
Modified: 2016-09-28 21:03 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 7.0
Last reconfirmed: 2016-09-21 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Sebor 2016-09-21 20:24:53 UTC
The gimple-ssa-sprintf.c pass crashes on a %lf directive:

$ cat v.c && /build/gcc-trunk-svn/gcc/xgcc -B /build/gcc-trunk-svn/gcc -S -Wall -Wformat -Wextra -Wpedantic v.c
char d [3];

void f (double x)
{
  __builtin_sprintf (d, "%lf", x);
}
v.c: In function ‘f’:
v.c:3:6: internal compiler error: in format_floating, at gimple-ssa-sprintf.c:1163
 void f (double x)
      ^
0x181ba7e format_floating
	/src/gcc-svn/gcc/gimple-ssa-sprintf.c:1163
0x181c8b2 format_floating
	/src/gcc-svn/gcc/gimple-ssa-sprintf.c:1373
0x181d144 format_directive
	/src/gcc-svn/gcc/gimple-ssa-sprintf.c:1626
0x181e794 compute_format_length
	/src/gcc-svn/gcc/gimple-ssa-sprintf.c:2320
0x181f516 handle_gimple_call
	/src/gcc-svn/gcc/gimple-ssa-sprintf.c:2645
0x181f5f1 execute
	/src/gcc-svn/gcc/gimple-ssa-sprintf.c:2671
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Martin Sebor 2016-09-21 22:42:19 UTC
Patch posted for review:
https://gcc.gnu.org/ml/gcc-patches/2016-09/msg01470.html
Comment 2 Martin Sebor 2016-09-27 17:24:16 UTC
*** Bug 77740 has been marked as a duplicate of this bug. ***
Comment 3 Martin Sebor 2016-09-28 16:13:44 UTC
Author: msebor
Date: Wed Sep 28 16:13:12 2016
New Revision: 240583

URL: https://gcc.gnu.org/viewcvs?rev=240583&root=gcc&view=rev
Log:
PR middle-end/77683 - ICE on %lf directive in format_floating in

gcc/testsuite/ChangeLog:

	PR middle-end/77683
	* gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: Add test cases.

gcc/ChangeLog:

	PR middle-end/77683
	* gimple-ssa-sprintf.c (format_integer): Fail gracefully when
	length modifier is not expected.
	(format_floating): Ignore l length modifier and fail gracefuly
	when it isn't one of the other expected ones.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/gimple-ssa-sprintf.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c
Comment 4 Martin Sebor 2016-09-28 16:16:28 UTC
Fixed by r240583.
Comment 5 Gerald Pfeifer 2016-09-28 21:03:22 UTC
Also verified with the testcase from Bug 77740: building Wine.