Unexpected results from _Bool cast

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Unexpected results from _Bool cast

Dave Keck
Hey list,

The following program outputs '0' when compiled on my system with `clang a.c`:

    #include <stdio.h>
    int main(int argc, const char *argv[])
    {
        printf("%d\n", (_Bool)((void *)0xCAFEBABE));
        return 0;
    }

Could someone confirm this is a bug? (Section 6.3.1.2 of C99 seems to
suggest that it is.) I suspect I need to upgrade Xcode/clang/llvm, but
I thought I'd check before I attempt to download that monstrosity on
my wee connection.

Thanks,

David
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected results from _Bool cast

Chris Lattner

On Dec 5, 2010, at 1:04 AM, Dave Keck wrote:

> Hey list,
>
> The following program outputs '0' when compiled on my system with `clang a.c`:
>
>    #include <stdio.h>
>    int main(int argc, const char *argv[])
>    {
>        printf("%d\n", (_Bool)((void *)0xCAFEBABE));
>        return 0;
>    }
>
> Could someone confirm this is a bug? (Section 6.3.1.2 of C99 seems to
> suggest that it is.) I suspect I need to upgrade Xcode/clang/llvm, but
> I thought I'd check before I attempt to download that monstrosity on
> my wee connection.

Yep, that would be a bug to print 0.  It works for me with mainline though,

-Chris
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev