re PR c/80919 (ICE: Segmentation fault with -Wall when printing address of size 0 array)

PR c/80919
	* c-format.c (matching_type_p): Return false if any of the types
	requires structural equality.

	* gcc.dg/format/pr80919.c: New test.

From-SVN: r248963
This commit is contained in:
Marek Polacek 2017-06-07 11:29:34 +00:00 committed by Marek Polacek
parent d27af1ff8a
commit 2904f6ac8e
4 changed files with 39 additions and 0 deletions

View File

@ -1,3 +1,12 @@
2017-06-07 Marek Polacek <polacek@redhat.com>
Backport from mainline
2017-06-04 Marek Polacek <polacek@redhat.com>
PR c/80919
* c-format.c (matching_type_p): Return false if any of the types
requires structural equality.
2017-05-02 Release Manager
* GCC 7.1.0 released.

View File

@ -3147,6 +3147,12 @@ matching_type_p (tree spec_type, tree arg_type)
gcc_assert (spec_type);
gcc_assert (arg_type);
/* If any of the types requires structural equality, we can't compare
their canonical types. */
if (TYPE_STRUCTURAL_EQUALITY_P (spec_type)
|| TYPE_STRUCTURAL_EQUALITY_P (arg_type))
return false;
spec_type = TYPE_CANONICAL (spec_type);
arg_type = TYPE_CANONICAL (arg_type);

View File

@ -1,3 +1,11 @@
2017-06-07 Marek Polacek <polacek@redhat.com>
Backport from mainline
2017-06-04 Marek Polacek <polacek@redhat.com>
PR c/80919
* gcc.dg/format/pr80919.c: New test.
2017-06-06 Michael Meissner <meissner@linux.vnet.ibm.com>
Back port from mainline

View File

@ -0,0 +1,16 @@
/* PR c/80919 */
/* { dg-do compile } */
/* { dg-options "-Wall" } */
void
fn (void)
{
int a[0];
__builtin_printf("%d\n", &a); /* { dg-warning "expects argument of type" } */
__builtin_printf("%i\n", &a); /* { dg-warning "expects argument of type" } */
__builtin_printf("%o\n", &a); /* { dg-warning "expects argument of type" } */
__builtin_printf("%u\n", &a); /* { dg-warning "expects argument of type" } */
__builtin_printf("%x\n", &a); /* { dg-warning "expects argument of type" } */
__builtin_printf("%X\n", &a); /* { dg-warning "expects argument of type" } */
}