<br><br><div class="gmail_quote">Le 1 février 2012 16:38, Mansour Moufid <span dir="ltr"><<a href="mailto:mansourmoufid@gmail.com">mansourmoufid@gmail.com</a>></span> a écrit :<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
Clang is producing curious warnings about certain large (in magnitude)<br>
negative integer values.<br>
<br>
I have a.c:<br>
<br>
    #include <limits.h><br>
    #include <stdio.h><br>
    int main(void) {<br>
        long int x = -9223372036854775808L;<br>
        printf("%li\n", x);<br>
        printf("%li\n", LONG_MIN);<br>
        return 0;<br>
    }<br>
<br>
Running the compiled executable produces the two lines:<br>
<br>
    -9223372036854775808<br>
    -9223372036854775808<br>
<br>
but compiling produced the warning:<br>
<br>
    a.c:4:19: warning: integer constant is so large that it is unsigned<br>
        long int x = -9223372036854775808L;<br>
                      ^<br>
    1 warning generated.<br>
<br>
The preprocessor gives:<br>
<br>
    ...<br>
    # 3 "a.c" 2<br>
    int main(void) {<br>
        long int x = -9223372036854775808L;<br>
        printf("%li\n", x);<br>
        printf("%li\n", (-9223372036854775807L - 1L));<br>
        return 0;<br>
    }<br>
<br>
So obviously the warning is incorrect. Is there a reason that warning<br>
is produced here?<br>
<br>
Mansour<br></blockquote></div><br>For what it's worth, gcc (4.3.2) is affected by the very same warning. It seems bogus and is probably due to the fact that the 9223372036854775808L would be too large for the type.<br>
<br>--Matthieu<br>