Reputation: 199
I am trying to compile a simple code with gcc and clang. the gcc generates a warning for 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
Am I passing all the necessary options to clang compiler or missing something? The clang documentation isn't a great help!
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
Upvotes: 0
Views: 354
Reputation: 199
I have reached out to the clang developers (mailing list). I have got this response:
In C++ mode, Clang errors on the line, same as everyone else. In C mode, however, conversions are typically more permissive. In this case, I suspect Clang should generate this warning as well. It’ll likely require a patch however.
Upvotes: 1