re PR middle-end/66345 (internal compiler error: Segmentation fault)

PR middle-end/66345
	* gimple-fold.c (gimple_fold_builtin_snprintf): Return false if
	get_maxval_strlen does not produce an INTEGER_CST.

	* gcc.dg/torture/pr66345.c: New test.

From-SVN: r224016
This commit is contained in:
Marek Polacek 2015-06-02 09:13:29 +00:00 committed by Marek Polacek
parent fc7e20fd7a
commit af9db3a7b0
4 changed files with 22 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2015-06-02 Marek Polacek <polacek@redhat.com>
PR middle-end/66345
* gimple-fold.c (gimple_fold_builtin_snprintf): Return false if
get_maxval_strlen does not produce an INTEGER_CST.
2015-06-02 Richard Sandiford <richard.sandiford@arm.com>
* config/arc/constraints.md: Use lower-case names in match_code.

View File

@ -2530,7 +2530,7 @@ gimple_fold_builtin_snprintf (gimple_stmt_iterator *gsi)
return false;
tree orig_len = get_maxval_strlen (orig, 0);
if (!orig_len)
if (!orig_len || TREE_CODE (orig_len) != INTEGER_CST)
return false;
/* We could expand this as

View File

@ -1,3 +1,8 @@
2015-06-02 Marek Polacek <polacek@redhat.com>
PR middle-end/66345
* gcc.dg/torture/pr66345.c: New test.
2015-06-02 Richard Biener <rguenther@suse.de>
PR tree-optimization/65961

View File

@ -0,0 +1,10 @@
/* { dg-do compile } */
extern int snprintf (char *, unsigned long, const char *, ...);
const char a[] = "";
int b;
void
get_bar ()
{
snprintf (0, 0, "%s", &a[b]);
}