[LLVMbugs] [Bug 19649] New: glibc exposed issue: wide character literal fails to behave as literal of its underlying type in preprocessor conditions

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat May 3 19:58:22 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19649

            Bug ID: 19649
           Summary: glibc exposed issue: wide character literal fails to
                    behave as literal of its underlying type in
                    preprocessor conditions
           Product: clang
           Version: 3.4
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hstong at ca.ibm.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140504/ea3ffa7c/attachment.html>


More information about the llvm-bugs mailing list