<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - glibc exposed issue: wide character literal fails to behave as literal of its underlying type in preprocessor conditions"
   href="http://llvm.org/bugs/show_bug.cgi?id=19649">19649</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>glibc exposed issue: wide character literal fails to behave as literal of its underlying type in preprocessor conditions
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.4
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>hstong@ca.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Certain versions of glibc use conditional inclusion to decide on the definition
of WCHAR_MIN. Clang picks the wrong definition.

According to C99 subclause 6.4.4.4 paragraph 11:
A wide character constant has type wchar_t, an integer type defined in the
<stddef.h> header.

The following source demonstrates that Clang will not treat a wide character
constant in the controlling expression of a preprocessing directive for
conditional inclusion in a way that is consistent with the above.

In particular, wchar_t is a synonym for int on the system in question (as
shown).
L'\0' does not behave consistently with 0 although both have the same type.


### SOURCE:> cat wchar_tPlay.c 
extern __typeof__(L'\0') wchar;
extern int wchar;

#if (L'\0' - 1 < 0) != (0 - 1 < 0)
# warning
#endif
Return:  0x00:0


### COMPILER INVOCATION AND OUTPUT:> clang -std=c99 wchar_tPlay.c -c
wchar_tPlay.c:5:3: warning:  [-W#warnings]
# warning
  ^
1 warning generated.
Return:  0x00:0


### VERSION INFO:> clang -v
clang version 3.4 (tags/RELEASE_34/final)
Target: powerpc64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/ppc64-redhat-linux/4.4.4
Found candidate GCC installation: /usr/lib/gcc/ppc64-redhat-linux/4.4.6
Selected GCC installation: /usr/lib/gcc/ppc64-redhat-linux/4.4.6
Return:  0x00:0</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>