+2018-02-08 Marek Polacek <polacek@redhat.com>
+
+ PR tree-optimization/84238
+ * tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Verify the result of
+ get_range_strlen.
+
2018-02-08 Richard Sandiford <richard.sandiford@linaro.org>
PR tree-optimization/84265
+2018-02-08 Marek Polacek <polacek@redhat.com>
+
+ PR tree-optimization/84238
+ * gcc.dg/Wstringop-overflow-3.c: New test.
+
2018-02-08 Nathan Sidwell <nathan@acm.org>
* g++.dg/cpp0x/initlist93.C: Adjust diagnostic.
--- /dev/null
+/* PR tree-optimization/84238 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+char a[1];
+int b;
+char *strncpy (char *, char *, __SIZE_TYPE__);
+void
+c ()
+{
+ char d[b];
+ strncpy (a, &d[3], 3); /* { dg-warning "writing 3 bytes into a region of size 1" } */
+}
{
tree range[2];
get_range_strlen (src, range);
- if (range[0])
+ if (range[0] != NULL_TREE
+ && TREE_CODE (range[0]) == INTEGER_CST
+ && range[1] != NULL_TREE
+ && TREE_CODE (range[1]) == INTEGER_CST)
{
lenrange[0] = wi::to_wide (range[0], prec);
lenrange[1] = wi::to_wide (range[1], prec);