[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: warnings in unit tests
From: |
Dmitry V. Levin |
Subject: |
Re: warnings in unit tests |
Date: |
Wed, 9 Jun 2021 16:35:41 +0300 |
On Tue, Jun 08, 2021 at 09:42:55AM -0700, Paul Eggert wrote:
> For what it's worth I'm more with Bruno on this. For the tests, the cost
> of these warnings outweighs the benefit.
>
> It'd be OK with me to disable the troublesome warnings globally for the
> tests subdirectory, using -Wno-missing-prototypes or whatever.
>
> For the -Wnull-dereference issue it may be worthwhile to use a
> circumlocution that fools GCC into not issuing the warning. After all, a
> compiler smart enough to warn about '*(volatile int *) 0 = 42' might
> also be smart enough to see that it's undefined behavior and therefore
> omit the assignment's effect entirely. Perhaps something like the
> attached (untested) patch?
> diff --git a/tests/test-sigsegv-catch-stackoverflow2.c
> b/tests/test-sigsegv-catch-stackoverflow2.c
> index b94d1310b..bfd4617a3 100644
> --- a/tests/test-sigsegv-catch-stackoverflow2.c
> +++ b/tests/test-sigsegv-catch-stackoverflow2.c
> @@ -50,6 +50,7 @@ sigset_t mainsigset;
>
> volatile int pass = 0;
> uintptr_t page;
> +int volatile *null_pointer_to_volatile;
>
> static void
> stackoverflow_handler_continuation (void *arg1, void *arg2, void *arg3)
> @@ -183,7 +184,7 @@ main ()
> *(volatile int *) (page + 0x678) = 42;
> break;
> case 3:
> - *(volatile int *) 0 = 42;
> + *null_pointer_to_volatile = 42;
> break;
> case 4:
> break;
Thanks, this patch works, I'd definitely prefer applying it rather than
disabling -Wnull-dereference.
--
ldv
- Re: new module 'sigsegv', (continued)
- Re: new module 'sigsegv', Bruno Haible, 2021/06/06
- Re: new module 'sigsegv', Dmitry V. Levin, 2021/06/07
- Re: new module 'sigsegv', Jim Meyering, 2021/06/07
- warnings in unit tests, Bruno Haible, 2021/06/07
- Re: warnings in unit tests, Jim Meyering, 2021/06/08
- Re: warnings in unit tests, Bruno Haible, 2021/06/08
- Re: warnings in unit tests, Dmitry V. Levin, 2021/06/08
- Re: warnings in unit tests, Bruno Haible, 2021/06/10
- Message not available
- Re: warnings in unit tests, Bruno Haible, 2021/06/08
- Re: warnings in unit tests, Paul Eggert, 2021/06/08
- Re: warnings in unit tests,
Dmitry V. Levin <=
- Re: warnings in unit tests, Bruno Haible, 2021/06/09
- Re: warnings in unit tests, Bruno Haible, 2021/06/10
- Re: warnings in unit tests, Bernhard Voelker, 2021/06/09
- Re: warnings in unit tests, Bruno Haible, 2021/06/09
- Re: warnings in unit tests, Simon Josefsson, 2021/06/10
- Re: warnings in unit tests, Bruno Haible, 2021/06/10
- Re: warnings in unit tests, Simon Josefsson, 2021/06/10
- Re: warnings in unit tests, Eric Blake, 2021/06/11
- Re: warnings in unit tests, Bruno Haible, 2021/06/11
Re: new module 'sigsegv', Bruno Haible, 2021/06/19