# HG changeset patch # User Bruno Haible # Date 1292799114 -3600 # Node ID 685711dc2effd4939981a324097cf62d9bfd8c3d # Parent 48d94880b592ac477cfb6528a2138d701b8f86d6 stdbool test: Avoid a gcc warning. * tests/test-stdbool.c (main): Fail if e1 is false. Reported by Jim Meyering. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-12-19 Bruno Haible + + stdbool test: Avoid a gcc warning. + * tests/test-stdbool.c (main): Fail if e1 is false. + Reported by Jim Meyering. + 2010-12-19 Jim Meyering setenv: restore to working order diff --git a/tests/test-stdbool.c b/tests/test-stdbool.c --- a/tests/test-stdbool.c +++ b/tests/test-stdbool.c @@ -90,10 +90,16 @@ int main () { + int error = 0; + #if HAVE_STDBOOL_H || defined __GNUC__ /* See above. */ # ifdef ADDRESS_CHECK_OKAY /* Avoid gcc warning. */ /* A cast from a variable's address to bool is valid in expressions. */ - bool e1 = &s; + { + bool e1 = &s; + if (!e1) + error = 1; + } # endif #endif @@ -102,6 +108,11 @@ http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html This is a runtime test, since a corresponding compile-time test would rely on initializer extensions. */ - char digs[] = "0123456789"; - return &(digs + 5)[-2 + (bool) 1] != &digs[4]; + { + char digs[] = "0123456789"; + if (&(digs + 5)[-2 + (bool) 1] != &digs[4]) + error = 1; + } + + return error; }