[LLVMbugs] [Bug 23562] New: clang does not build binutils/gdb when -D_FORTIFY_SOURCE=2 and -O2 are set.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon May 18 11:27:37 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=23562

            Bug ID: 23562
           Summary: clang does not build binutils/gdb when
                    -D_FORTIFY_SOURCE=2 and -O2 are set.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: yunlian at chromium.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Below is a reduced case when building binutils/gdb with clang. This code
compiles well if -D_FORTIFY_SOURCE=2 and -O2 are not set. It pops out the
following error if -D_FORTIFY_SOURCE=2 and -O2 are set. gcc does not have this
problem.

cat f.c
<<<<<<<<
#define _GNU_SOURCE
#define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))

#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
ATTRIBUTE_NONNULL(m)
#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
#include <stdio.h>
extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
>>>>>>>>>>>>>>>



 /usr/bin/clang   -D_FORTIFY_SOURCE=2 -c -O2 ./f.c -o a
-B/usr/libexec/gcc/x86_64-cros-linux-gnu -target x86_64-cros-linux-gnu




./f.c:30:12: error: expected parameter declarator
extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
           ^
/usr/include/bits/stdio2.h:199:24: note: expanded from macro 'asprintf'
  __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
                       ^
/usr/include/features.h:346:31: note: expanded from macro '__USE_FORTIFY_LEVEL'
#  define __USE_FORTIFY_LEVEL 2
                              ^
./f.c:30:12: error: expected ')'
/usr/include/bits/stdio2.h:199:24: note: expanded from macro 'asprintf'
  __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
                       ^
/usr/include/features.h:346:31: note: expanded from macro '__USE_FORTIFY_LEVEL'
#  define __USE_FORTIFY_LEVEL 2
                              ^
./f.c:30:12: note: to match this '('
/usr/include/bits/stdio2.h:199:18: note: expanded from macro 'asprintf'
  __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
                 ^
./f.c:30:50: error: '__nonnull__' attribute parameter 1 is out of bounds
extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
                                                 ^~~~~~~~~~~~~~~~~~
./f.c:26:28: note: expanded from macro 'ATTRIBUTE_PRINTF_2'
#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
                           ^                ~
./f.c:25:80: note: expanded from macro 'ATTRIBUTE_PRINTF'
#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
ATTRIBUTE_NONNULL(m)
                                                                              
^
./f.c:23:46: note: expanded from macro 'ATTRIBUTE_NONNULL'
#define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
                                             ^
./f.c:30:50: error: '__format__' attribute parameter 2 is out of bounds
extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
                                                 ^~~~~~~~~~~~~~~~~~
./f.c:26:28: note: expanded from macro 'ATTRIBUTE_PRINTF_2'
#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
                           ^                ~
./f.c:25:48: note: expanded from macro 'ATTRIBUTE_PRINTF'
#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
ATTRIBUTE_NONNULL(m)
                                               ^
./f.c:30:12: error: conflicting types for '__asprintf_chk'
extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
           ^
/usr/include/bits/stdio2.h:199:3: note: expanded from macro 'asprintf'
  __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
  ^
/usr/include/bits/stdio2.h:158:12: note: previous declaration is here
extern int __asprintf_chk (char **__restrict __ptr, int __flag,
           ^
5 errors generated.

-- 
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/20150518/7fffe5c3/attachment.html>


More information about the llvm-bugs mailing list