Commit 9304142e by Jakub Jelinek

re PR middle-end/40502 (crash in cp_diagnostic_starter)

	PR c++/40502
	* error.c (cp_print_error_function): Check for NULL block.

	* g++.dg/ext/strncpy-chk1.C: New test.

From-SVN: r149470
parent 182e00b1
2009-07-10 Jakub Jelinek <jakub@redhat.com>
PR c++/40502
* error.c (cp_print_error_function): Check for NULL block.
2008-07-09 Simon Martin <simartin@users.sourceforge.net> 2008-07-09 Simon Martin <simartin@users.sourceforge.net>
Jason Merrill <jason@redhat.com> Jason Merrill <jason@redhat.com>
* pt.c (perform_typedefs_access_check, get_types_needing_access_check, * pt.c (perform_typedefs_access_check, get_types_needing_access_check,
append_type_to_template_for_access_check_1): Use CLASS_TYPE_P. append_type_to_template_for_access_check_1): Use CLASS_TYPE_P.
......
...@@ -2603,7 +2603,7 @@ cp_print_error_function (diagnostic_context *context, ...@@ -2603,7 +2603,7 @@ cp_print_error_function (diagnostic_context *context,
while (block && TREE_CODE (block) == BLOCK) while (block && TREE_CODE (block) == BLOCK)
block = BLOCK_SUPERCONTEXT (block); block = BLOCK_SUPERCONTEXT (block);
if (TREE_CODE (block) == FUNCTION_DECL) if (block && TREE_CODE (block) == FUNCTION_DECL)
fndecl = block; fndecl = block;
abstract_origin = NULL; abstract_origin = NULL;
} }
......
2009-07-10 Jakub Jelinek <jakub@redhat.com>
PR c++/40502
* g++.dg/ext/strncpy-chk1.C: New test.
2009-07-10 Richard Guenther <rguenther@suse.de> 2009-07-10 Richard Guenther <rguenther@suse.de>
PR tree-optimization/40496 PR tree-optimization/40496
......
// PR c++/40502
// { dg-do compile }
// { dg-options "-O2" }
struct A { char x[12], y[35]; };
struct B { char z[50]; };
inline void
foo (char *dest, const char *__restrict src, __SIZE_TYPE__ n)
{
__builtin___strncpy_chk (dest, src, n, __builtin_object_size (dest, 0)); // { dg-warning "will always overflow" }
}
void bar (const char *, int);
inline void
baz (int i)
{
char s[128], t[32];
bar (s, 0);
bar (t, i);
A a;
B b;
foo (a.y, b.z, 36);
}
void
test ()
{
baz (0);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment