bug-autoconf
[Top][All Lists]
Advanced

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

Re: stdbool.h test v. Compaq C on Tru64


From: Steven M. Schweda
Subject: Re: stdbool.h test v. Compaq C on Tru64
Date: Tue, 23 Oct 2007 09:54:06 -0500 (CDT)

From: Paul Eggert <address@hidden>

> >    I suppose that if your goal is to reveal fairly exotic compiler
> > quirks rather than to test for a usable stdbool.h,
> 
> Well, one person's "compiler quirks" are another person's "features"....

   Right.  Well, just for the record, my abbreviated version of the
feature-packed autoconf test using the Tru64 system stdbool.h failed
like this:

urtx# cat ct_bd.c
#include <stdbool.h>

struct s { _Bool s: 1; _Bool t; } s;
bool e = &s;

int main( void) {}

urtx# cc -c ct_bd.c
cc: Error: ct_bd.c, line 4: In the initializer for e, the address cannot be conv
erted to the destination type. (badstaticcvt)
bool e = &s;
---------^


   Now, having failed that (deluxe, rigorous) test, we can advance to
the (newly revised) gnulib stdbool.h, which does _so_ much better:

urtx# cat gl_bd.c
#include "stdbool.h"

struct s { _Bool s: 1; _Bool t; } s;
bool e = &s;

int main( void) {}

urtx# cc -c gl_bd.c
cc: Warning: gl_bd.c, line 4: In the initializer for e, "&s" of type "pointer to
 struct s", is being converted to "signed char". (cvtdiftypes)
bool e = &s;
---------^
cc: Warning: gl_bd.c, line 4: In the initializer for e, "&s" has a larger data s
ize than "signed char".  Assignment can result in data loss.
(maylosedata)
bool e = &s;
---------^
cc: Error: gl_bd.c, line 4: In the initializer for e, the address cannot be conv
erted to the destination type. (badstaticcvt)
bool e = &s;
---------^


   Some people might conclude that that was not a real improvement, but
I find that the warnings make for a nice glide up the complaint
intensity scale, so that the the final "Error:" is less of a jolt.  Now,
I'm sure glad that we've avoided using that pesky C99-non-compliant
Tru64 stdbool.h, in favor of its superior replacement which solves all
the problems caused by its inferior.  (Well, all except for the one
which caused the original test to fail.)

   I remain curious as to why the variable scope change which I
suggested for the autoconf stdbool.h test would in any way violate its
(claimed) purpose, but I can see that the current test is a source of
much pride, so I'll try not to be such a bother in the future.

   Thanks again for the gnulib stdbool.h change, irregardful.

   SMS.




reply via email to

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