gcc/testsuite/ChangeLog:
* gcc.dg/builtin-sprintf-warn-20.c: New test.
From-SVN: r263676
+2018-08-20 Martin Sebor <msebor@redhat.com>
+
+ PR tree-optimization/87034
+ * gcc.dg/builtin-sprintf-warn-20.c: New test.
+
2018-08-20 David Malcolm <dmalcolm@redhat.com>
PR other/84889
--- /dev/null
+/* PR tree-optimization/87034 - missing -Wformat-overflow on a sprintf
+ %s with a wide string
+ { dg-do compile }
+ { dg-options "-O2 -Wall -Wformat-overflow -ftrack-macro-expansion=0" } */
+
+typedef __WCHAR_TYPE__ wchar_t;
+
+extern int sprintf (char*, const char*, ...);
+
+struct S
+{
+ char a[1];
+ void (*pf)(void);
+};
+
+void test (struct S *p)
+{
+ const char *q = sizeof (wchar_t) == 2
+ ? (char*)L"\x4142\x4344" : (char*)L"\x41424344\x45464748";
+
+ sprintf (p->a, "%s", q); /* { dg-warning "\\\[-Wformat-overflow" "pr87034" { xfail *-*-*} } */
+}