On Mon, Jun 7, 2021 at 3:29 AM Dmitry V. Levin <l...@altlinux.org> wrote: > Hi, > On Mon, Jun 07, 2021 at 02:49:35AM +0200, Bruno Haible wrote: > [...] [...] > > > @@ -183,6 +183,9 @@ main () > > > *(volatile int *) (page + 0x678) = 42; > > > break; > > > case 3: > > > +#if 6 < __GNUC__ > > > +# pragma GCC diagnostic ignored "-Wnull-dereference" > > > +#endif > > > *(volatile int *) 0 = 42; > > > break; > > > case 4: > > > > We shouldn't spend time eliminating warnings from test code. > > > > The goal is to have a good coverage of the lib/* code with unit tests. > > That means, we need to > > - make it easy to write unit tests, > > - not make it time-consuming to maintain them. > > > > Eliminating warnings from lib/* code is useful, to avoid bugs in the > > programs. But eliminating warnings from tests/* code goes against the > > goal of increasing test coverage.
Hi Bruno, Isn't this code exceptional enough to merit three lines of warning suppression? I would like to continue to use -Werror with most warning options even in test code, as long as the cost is low. This feels like a very low one-time cost. > > I think the right fix would be that gnulib-tool's --import/--update > > option, when creating a tests directory, adds a $(CFLAG_ALLOW_WARNING) > > to tests/Makefile.am, where CFLAG_ALLOW_WARNING is defined as > > -Wno-error when the compiler is GCC or clang, > > empty otherwise > > Will that work in GNU grep? I would prefer not to exempt all of grep/gnulib's test code from -Werror -Wnull-dereference just to accommodate this one unusual case.