bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] test-stdbool: skip test that fails with Solaris CC


From: Eric Blake
Subject: [PATCH] test-stdbool: skip test that fails with Solaris CC
Date: Fri, 16 Apr 2010 17:14:25 -0600

Solaris 9 CC has a bug; it allows (int)0.0 and (bool)0 in constant
expressions, but not (bool)0.0.  Our replacement stdbool cannot
provide that guarantee of C99 for this particular compiler, but
since use of that feature causes compilation failure rather than
silent mis-compilation, we just skip the test.

* tests/test-stdbool.c (f): Skip test that causes compilation
error under buggy C++ compiler.
* lib/stdbool.in.h: Document the limitation.
* doc/posix-headers/stdbool.texi (stdbool.h): Likewise.

Signed-off-by: Eric Blake <address@hidden>
---

> > Or do we go full-bore and use #if 0, skipping test f everywhere?
>
> I'd say so.  After all the worst thing this bug could cause is a
> compile-time failure, not miscompilation.

Sounds reasonable.  I'm pushing this.

 ChangeLog                      |    6 ++++++
 doc/posix-headers/stdbool.texi |    3 +++
 lib/stdbool.in.h               |    3 +++
 tests/test-stdbool.c           |    5 +++--
 4 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2360f0e..4d56e5a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2010-04-16  Eric Blake  <address@hidden>

+       test-stdbool: skip test that fails with Solaris CC
+       * tests/test-stdbool.c (f): Skip test that causes compilation
+       error under buggy C++ compiler.
+       * lib/stdbool.in.h: Document the limitation.
+       * doc/posix-headers/stdbool.texi (stdbool.h): Likewise.
+
        setenv: allow compilation with C++
        * lib/setenv.c (__add_to_environ): Add a cast.  Also, drop use of
        register keyword.
diff --git a/doc/posix-headers/stdbool.texi b/doc/posix-headers/stdbool.texi
index 94dca84..990c17b 100644
--- a/doc/posix-headers/stdbool.texi
+++ b/doc/posix-headers/stdbool.texi
@@ -27,4 +27,7 @@ stdbool.h
 Casts and automatic conversions to @samp{bool} don't test against the
 zero value or the null pointer, as they should.  Such casts should only
 be used if the casted value is known to be equal to 0 or 1.
address@hidden
+You cannot assume that casting floating point to @samp{bool} will
+result in a constant expression.
 @end itemize
diff --git a/lib/stdbool.in.h b/lib/stdbool.in.h
index 881faf3..d589cb4 100644
--- a/lib/stdbool.in.h
+++ b/lib/stdbool.in.h
@@ -50,6 +50,9 @@
          with this substitute.  With this substitute, only the values 0 and 1
          give the expected result when converted to _Bool' or 'bool'.

+       - C99 allows the use of (_Bool)0.0 in constant expressions, but
+         this substitute cannot always provide this property.
+
    Also, it is suggested that programs use 'bool' rather than '_Bool';
    this isn't required, but 'bool' is more common.  */

diff --git a/tests/test-stdbool.c b/tests/test-stdbool.c
index 560e0e5..fcb534d 100644
--- a/tests/test-stdbool.c
+++ b/tests/test-stdbool.c
@@ -46,11 +46,12 @@ struct s { _Bool s: 1; _Bool t; } s;
 char a[true == 1 ? 1 : -1];
 char b[false == 0 ? 1 : -1];
 char c[__bool_true_false_are_defined == 1 ? 1 : -1];
-#if 0 /* Cannot be guaranteed with gnulib's <stdbool.h>.  */
+#if 0 /* Cannot be guaranteed with gnulib's <stdbool.h>, at least,
+not for all compilers.  */
 char d[(bool) 0.5 == true ? 1 : -1];
 bool e = &s;
-#endif
 char f[(_Bool) 0.0 == false ? 1 : -1];
+#endif
 char g[true];
 char h[sizeof (_Bool)];
 #if 0 /* See above.  */
-- 
1.6.6.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]