Hi all,
I'm reporting this problem here, because apache.bugs seems flooded with
spam.
The way TRUE is defined in some apache headers files is incorrect :
modules/ssl/ssl_expr.h:35:#define TRUE !FALSE
apache/ap_ctx.h:70:#define TRUE !FALSE
apache/ap_hook.h:358:#define TRUE !FALSE
apache/ap_mm.h:70:#define TRUE !FALSE
missing parentheses may cause incorrect expression results, because of
operator precedence.
I agree that it is a remote possibility, because unary prefix operator have
a high precedence, but it is still possible, and as such should not stay in
published header files.
The program below illustrates this possibility :
#include <stdio.h>
int main(int argc, char **argv)
{
#undef TRUE
#undef FALSE
#define FALSE 0
#define TRUE 1
printf("#define FALSE 0\n#define TRUE 1\n");
printf("'N' = %d <-> FALSE[\"NY\"] = %d\n", 'N', FALSE["NY"]);
printf("'Y' = %d <-> TRUE[\"NY\"] = %d\n", 'Y', TRUE["NY"]);
#undef TRUE
#undef FALSE
#define FALSE 0
#define TRUE !FALSE
printf("#define FALSE 0\n#define TRUE !FALSE\n");
printf("'N' = %d <-> FALSE[\"NY\"] = %d\n", 'N', FALSE["NY"]);
printf("'Y' = %d <-> TRUE[\"NY\"] = %d\n", 'Y', TRUE["NY"]);
return 0;
}
output is :
#define FALSE 0
#define TRUE 1
'N' = 78 <-> FALSE["NY"] = 78
'Y' = 89 <-> TRUE["NY"] = 89
#define FALSE 0
#define TRUE !FALSE
'N' = 78 <-> FALSE["NY"] = 78
'Y' = 89 <-> TRUE["NY"] = 0
Just my 2 cents ;-)
Charlie Gordon.
The C teaser.