[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: stdbool.h with AIX C-compiler
From: |
Heinrich Mislik |
Subject: |
Re: stdbool.h with AIX C-compiler |
Date: |
Fri, 16 May 2008 13:19:10 +0200 |
On 15 May 2008 at 20:39, Eric Blake wrote:
> Heinrich Mislik <Heinrich.Mislik <at> univie.ac.at> writes:
>
> Hello Heinrich, and thanks for the report.
>
> > here is a problem with stdbool.h from gnulib:
> > pbool(256);
>
> Inherently non-portable when attempted with a C89 compiler. And
> Gnulib's
> <stdbool.h> replacement documents it as one of the limitations of
> using the
> replacement <stdbool.h>:
>
> | Limitations of this substitute, when used in a C89
> environment:
> |
> | - <stdbool.h> must be #included before the '_Bool' type can
> be used.
> |
> | - You cannot assume that _Bool is a typedef; it might be a
> macro.
> |
> | - Bit-fields of type 'bool' are not supported. Portable
> code
> | should use 'unsigned int foo : 1;' rather than 'bool foo :
> 1;'.
> |
> | - In C99, casts and automatic conversions to '_Bool' or
> 'bool' are
> | performed in such a way that every nonzero value gets
> converted
> | to 'true', and zero gets converted to 'false'. This
> doesn't work
> | with this substitute. With this substitute, only the
> values 0 and 1
> | give the expected result when converted to _Bool' or
> 'bool'.
>
> > I came across this, when the -iregex option of find didn't work
> > (behaves like -regex). The above test-program reflects the
> situation
> > in line 778 of regcomp.c:
> >
> > err = re_string_construct (®exp, pattern, length,
> preg-translate,
> > syntax & RE_ICASE, dfa);
>
> Therefore the bug is in regcomp.c, for violating the limits of
> <stdbool.h>
> usage. The proper fix is not in the stdbool module (since there is
> no way to
> make C89 behave the way C99 requires bool to act), but in the regex
> module, to
> explicitly compare the result of & against 0 in order to create a
> true 0/1
> value regardless of what underlying type we are really using.
After reading the comments in stdbool.h I came to the same conclusion
and to the same fix. After that -iregex was completly broken. I found
one second place, that needs the same change:
Line 703 in regexec.c is now:
err = re_string_allocate (&mctx.input, string, length,
dfa->nodes_len + 1,
preg->translate, (preg->syntax & RE_ICASE) != 0, dfa);
Now -iregex seems to work OK. But as you mentioned, there may be more
gotchas around.
Regarding your other mail:
Attached find the relevant parts from config.log. I don't now, wether
the compiler is in error here. And reporting bugs for AIX costs a lot
of time, which I don't have right now.
Cheers
Heinrich
--
Heinrich Mislik
Zentraler Informatikdienst der Universitaet Wien
A-1010 Wien, Universitaetsstrasse 7
Tel.: (+43 1) 4277-14056, Fax: (+43 1) 4277-9140
The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any other MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.
---- File information -----------
File: config.log.bool
Date: 16 May 2008, 13:04
Size: 5577 bytes.
Type: Unknown
config.log.bool
Description: Binary data