r243582 - in /trunk/gcc: ChangeLog gimple-ssa-s...

msebor@gcc.gnu.org msebor@gcc.gnu.org
Mon Dec 12 21:56:00 GMT 2016


Author: msebor
Date: Mon Dec 12 21:56:22 2016
New Revision: 243582

URL: https://gcc.gnu.org/viewcvs?rev=243582&root=gcc&view=rev
Log:
PR middle-end/78622 - -Wformat-length/-fprintf-return-value incorrect with overflow/wrapping

gcc/ChangeLog:

	PR middle-end/78622
	PR middle-end78606
	* gimple-ssa-sprintf.c (min_bytes_remaining): Use res.knownrange
	rather than res.bounded.
	(get_width_and_precision): Set precision to -1 when negative.
	(adjust_range_for_overflow): New function.
	(format_integer): Correct the handling of the space, plus, and pound
	flags, and the special case of zero precision.
	Always set res.bounded to true unless either precision or width
	is specified and unknown.
	Call adjust_range_for_overflow.
	Avoid use zero as the shortest value when precision is specified
	but unknown.
	(format_directive): Remove vestigial quoting.  Always inform of
	argument value or range when it's available.
	(add_bytes): Correct the computation of boundrange used to
	decide whether a warning is of a "maybe" or "defnitely" kind.

gcc/testsuite/ChangeLog:

	PR middle-end/78622
	PR middle-end78606
	* gcc.c-torture/execute/pr78622.c: New test.
	* gcc.dg/tree-ssa/builtin-sprintf-2.c: Remove "benign" undefined
	behavior inadvertently introduced in a previous commit.  Tighten
	up final checking.
	* gcc.dg/tree-ssa/builtin-sprintf-5.c: Rename macros for clarity.
	Add test cases.
	* gcc.dg/tree-ssa/builtin-sprintf-6.c: Add test cases.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: Same.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-2.c: Same.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-3.c: Same.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-5.c: Same.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-6.c: Remove xfails and
	add a final optimization check.
	* gcc.dg/tree-ssa/builtin-sprintf.c: Add test cases.
	* gcc.dg/tree-ssa/pr78622.c: New test.


Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr78622.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/pr78622.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/gimple-ssa-sprintf.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-5.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-6.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-2.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-3.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-6.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf.c



More information about the Gcc-cvs mailing list