Failing to build test-cpu-policy.c with GCC9
diff mbox series

Message ID 20ec48febe15d329547b0dc4fe1e411e0043c4df.camel@suse.com
State New, archived
Headers show
Series
  • Failing to build test-cpu-policy.c with GCC9
Related show

Commit Message

Dario Faggioli July 26, 2019, 12:50 a.m. UTC
Hey, Andy,

openSUSE Tumbleweed has: gcc version 9.1.1 20190703

And this fails to build test-cpu-policy.c, like this:

test-cpu-policy.c: In function ‘main’:
test-cpu-policy.c:64:18: error: ‘%.12s’ directive argument is not a nul-terminated string [-Werror=format-overflow=]
   64 |             fail("  Test '%.12s', expected vendor %u, got %u\n",
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test-cpu-policy.c:20:12: note: in definition of macro ‘fail’
   20 |     printf(fmt, ##__VA_ARGS__);                 \
      |            ^~~
test-cpu-policy.c:64:27: note: format string is defined here
   64 |             fail("  Test '%.12s', expected vendor %u, got %u\n",
      |                           ^~~~~
test-cpu-policy.c:44:7: note: referenced argument declared here
   44 |     } tests[] = {
      |  

Even just doing something like below, seems to fix it for me, but there
probably are better ways...

Regards

---

Comments

Andrew Cooper July 26, 2019, 1:06 a.m. UTC | #1
On 26/07/2019 01:50, Dario Faggioli wrote:
> Hey, Andy,
>
> openSUSE Tumbleweed has: gcc version 9.1.1 20190703
>
> And this fails to build test-cpu-policy.c, like this:
>
> test-cpu-policy.c: In function ‘main’:
> test-cpu-policy.c:64:18: error: ‘%.12s’ directive argument is not a nul-terminated string [-Werror=format-overflow=]
>    64 |             fail("  Test '%.12s', expected vendor %u, got %u\n",
>       |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> test-cpu-policy.c:20:12: note: in definition of macro ‘fail’
>    20 |     printf(fmt, ##__VA_ARGS__);                 \
>       |            ^~~
> test-cpu-policy.c:64:27: note: format string is defined here
>    64 |             fail("  Test '%.12s', expected vendor %u, got %u\n",
>       |                           ^~~~~
> test-cpu-policy.c:44:7: note: referenced argument declared here
>    44 |     } tests[] = {
>       |  
>
> Even just doing something like below, seems to fix it for me, but there
> probably are better ways...

It's a compiler bug, but I haven't had time to file a ticket yet.

The claim in the warning is false.

~Andrew

Patch
diff mbox series

diff --git a/tools/tests/cpu-policy/test-cpu-policy.c b/tools/tests/cpu-policy/test-cpu-policy.c
index ca3b8dd45f..e0c2c56154 100644
--- a/tools/tests/cpu-policy/test-cpu-policy.c
+++ b/tools/tests/cpu-policy/test-cpu-policy.c
@@ -35,7 +35,7 @@  static void test_vendor_identification(void)
 {
     static const struct test {
         union {
-            char ident[12];
+            char ident[13];
             struct {
                 uint32_t b, d, c;
             };