[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
stdbool.h with AIX C-compiler
From: |
Heinrich Mislik |
Subject: |
stdbool.h with AIX C-compiler |
Date: |
Wed, 14 May 2008 12:57:14 +0200 |
Hi,
here is a problem with stdbool.h from gnulib:
# cat bool.c
#include <stdbool.h>
static pbool(bool b)
{
if(b) printf("true\n");
else printf("false\n");
}
main()
{
pbool(256);
}
# cc bool.c
# ./a.out
true
# cc bool.c -I findutils-4.4.0/gnulib/lib/
# ./a.out
false
# cc bool.c -E
#line 3 "bool.c"
static pbool(_Bool b)
{
if(b) printf("true\n");
else printf("false\n");
}
main()
{
pbool(256);
}
# cc bool.c -I findutils-4.4.0/gnulib/lib/ -E
#line 3 "bool.c"
static pbool(signed char b)
{
if(b) printf("true\n");
else printf("false\n");
}
main()
{
pbool(256);
}
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);
syntax & RE_ICASE implicitly casted to bool always give false.
I don't think, that the compliler is in error. Casting 256 to signed
char gives 0 and therefor false. So simply replacing _Bool with
signed char gives wrong results. This may happen with other compilers
as well.
Additional infos about the system:
# lslpp -l vac.C
Fileset Level State Description
--------------------------------------------------------------------
--------
Path: /usr/lib/objrepos
vac.C 7.0.0.0 COMMITTED IBM XL C Compiler
Path: /etc/objrepos
vac.C 7.0.0.0 COMMITTED IBM XL C Compiler
# uname -a
AIX fs1 3 5 00CFC8BD4C00
Thanks for your attention
Cheers
Heinrich--
Heinrich Mislik
Zentraler Informatikdienst der Universitaet Wien
A-1010 Wien, Universitaetsstrasse 7
Tel.: (+43 1) 4277-14056, Fax: (+43 1) 4277-9140