[LLVMbugs] [Bug 16988] New: clang's stdint.h forwarding can silently result in no standard integer types being defined.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Aug 24 11:51:02 PDT 2013


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

            Bug ID: 16988
           Summary: clang's stdint.h forwarding can silently result in no
                    standard integer types being defined.
           Product: clang
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zalman at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The clang internal version of stdint.h (llvm/tools/clang/lib/Headers/stdint.h)
forwards to a system version of stdint.h via include_next in certain
situations. If the next stdint.h file found via that forwarding is also clang's
header (e.g. the same file in a different tree of includes), it silently does
nothing since the file level include guard (__CLANG_STDINT_H) is already
defined at the time of forwarding.

Now I'm not sure if this is a serious issue in valid configurations or just a
hassle in strange cross compilation setups. An example of a valid case would be
the system compiler is clang and one is building a different version of clang.
Perhaps one is not supposed to use clang's internal stdint.h in e.g.
/usr/include. Even if so, it would be nice for this to turn into an error
instead of silently producing no definitions for stdint types.

One possible fix is to not define the include guard if forwarding. That would
involve moving the include guard inside the #else part of the #if that controls
forwarding. (This should never result in an infinite loop as the include_next
should finitely iterate a list of possible includes.) Another possible fix is
to do something like the following before "# include_next <stdint.h>":

    #define _CLANG_STDINT_H_FORWARDED

and before the include guard in llvm/tools/clang/lib/Headers/stdint.h put:

    #ifdef _CLANG_STDINT_H_FORWARDED
    #error "clang internal stdint.h forwarding to self. Bad compiler
configuration."
    #endif

-- 
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/20130824/bebd79df/attachment.html>


More information about the llvm-bugs mailing list