2017-01-03 Jakub Jelinek <jakub@redhat.com>
+ PR middle-end/78901
+ * gimple-ssa-sprintf.c (try_substitute_return_value): Don't change
+ possibly throwing calls.
+
* genmatch.c (dt_node::gen_kids_1): If generic_exprs include SSA_NAME
and exprs_len || fns_len, emit the code for SSA_NAME next to the exprs
and fns handling, rather than in a separate case SSA_NAME.
the output overflows the destination object (but leave it enabled
when the function is bounded because then the behavior is well-
defined). */
- if (lhs && res.bounded && res.under4k
+ if (lhs
+ && res.bounded
+ && res.under4k
&& (info.bounded || res.number_chars <= info.objsize)
- && res.number_chars - 1 <= target_int_max ())
+ && res.number_chars - 1 <= target_int_max ()
+ /* Not prepared to handle possibly throwing calls here; they shouldn't
+ appear in non-artificial testcases, except when the __*_chk routines
+ are badly declared. */
+ && !stmt_ends_bb_p (info.callstmt))
{
tree cst = build_int_cst (integer_type_node, res.number_chars - 1);
+2017-01-03 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/78901
+ * g++.dg/opt/pr78901.C: New test.
+
2017-01-03 Janne Blomqvist <jb@gcc.gnu.org>
- PR fortran/78534
- PR fortran/66310
- * gfortran.dg/dependency_49.f90: Change scan-tree-dump-times
- due to gfc_trans_string_copy change to avoid
- -Wstringop-overflow.
- * gfortran.dg/repeat_4.f90: Use integers of kind C_SIZE_T.
- * gfortran.dg/repeat_7.f90: New test for PR 66310.
- * gfortran.dg/scan_2.f90: Handle potential cast in assignment.
- * gfortran.dg/string_1.f90: Limit to ilp32 targets.
- * gfortran.dg/string_1_lp64.f90: New test.
- * gfortran.dg/string_3.f90: Limit to ilp32 targets.
- * gfortran.dg/string_3_lp64.f90: New test.
- * gfortran.dg/transfer_intrinsic_1.f90: Change
- scan-tree-dump-times due to gfc_trans_string_copy change to
- avoid -Wstringop-overflow.
+ PR fortran/78534
+ PR fortran/66310
+ * gfortran.dg/dependency_49.f90: Change scan-tree-dump-times
+ due to gfc_trans_string_copy change to avoid -Wstringop-overflow.
+ * gfortran.dg/repeat_4.f90: Use integers of kind C_SIZE_T.
+ * gfortran.dg/repeat_7.f90: New test for PR 66310.
+ * gfortran.dg/scan_2.f90: Handle potential cast in assignment.
+ * gfortran.dg/string_1.f90: Limit to ilp32 targets.
+ * gfortran.dg/string_1_lp64.f90: New test.
+ * gfortran.dg/string_3.f90: Limit to ilp32 targets.
+ * gfortran.dg/string_3_lp64.f90: New test.
+ * gfortran.dg/transfer_intrinsic_1.f90: Change
+ scan-tree-dump-times due to gfc_trans_string_copy change to
+ avoid -Wstringop-overflow.
2017-01-02 Uros Bizjak <ubizjak@gmail.com>
--- /dev/null
+// PR middle-end/78901
+// { dg-do compile }
+// { dg-options "-O2 -Wno-stringop-overflow" }
+
+extern "C" int __snprintf_chk (char *, __SIZE_TYPE__, int, __SIZE_TYPE__, const char *, ...);
+
+int
+foo (char *c)
+{
+ try
+ {
+ return __snprintf_chk (c, 64, 0, 32, "%s", "abcdefghijklmnopq");
+ }
+ catch (...)
+ {
+ return -1;
+ }
+}