[cfe-dev] Clang warning for invalid casting!

David John via cfe-dev cfe-dev at lists.llvm.org
Fri Jul 28 10:23:14 PDT 2017


So is there an answer for this inquiry or not?

Thank you!


On Wed, Jul 26, 2017 at 10:05 PM David John <davejohn.0405 at gmail.com> wrote:

> I am trying to compile a simple code (see below) with gcc and clang. the
> gcc generates a warning indicating an incomparable casting (great!).
> However, clang didn't generate any warnings! I have passed the same
> arguments for both:
>
> cc -Wall -Wextra tmp3.c
> gcc -Wall -Wextra tmp3.c
>
> Should I expect clang to generate error or not? If yes, is there an
> additional option needs to be passed to clang compiler to generate a
> warning for something that is obviously wrong?
>
> Code:
>
> int main(void)
> {
>    void *b = (void *)0x12345678;
>    int   a = (int)(unsigned long)b;
>    int   c = (int)b;
>    return a + c;
> }
>
>
> Clang version 3.8
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170728/00d20415/attachment.html>


More information about the cfe-dev mailing list