2008/7/3 Artur Grabowski <[EMAIL PROTECTED]>:
> "Arnaud Bergeron" <[EMAIL PROTECTED]> writes:
>
>> mt-daapd suffers from a case I've named 0.5:
>>
>> pointer -> int
>>
>> and then the int is used as a truth value. So this is not a bug.
>
> Not a bug? Really?
>
> $ cat foo.c
> int
> main()
> {
> int true;
> void *nonnull = (void *)0x7000000000000000;
>
> true = nonnull;
> printf(true ? "true\n" : "false\n");
> true = !!nonnull;
> printf(true ? "true\n" : "false\n");
> }
> $ make foo
> cc -O2 -pipe -o foo foo.c
> foo.c: In function `main':
> foo.c:7: warning: assignment makes integer from pointer without a cast
> $ ./foo
> false
> true
> $
>
> //art
I'll admit I didn't think about this. So I'll have to fix it. It
helps that most uses of the pointers look like that:
int main() {
int true = 1;
void *nonnull = (void *)0x7000000000000000;
true = true && nonnull;
printf("%d\n", true);
}
which does work correctly.
Arnaud