[Bug 3482] New: Compilation fails with clang

bugzilla-daemon at mindrot.org bugzilla-daemon at mindrot.org
Tue Oct 11 02:39:57 AEDT 2022


https://bugzilla.mindrot.org/show_bug.cgi?id=3482

            Bug ID: 3482
           Summary: Compilation fails with clang
           Product: Portable OpenSSH
           Version: 9.1p1
          Hardware: amd64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: Miscellaneous
          Assignee: unassigned-bugs at mindrot.org
          Reporter: julien at julien-bigot.fr

This issue is similar to
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98733 or
https://bugs.llvm.org/show_bug.cgi?id=23562 

Clang fails to compile `bsd-asprintf.c` that's part of openssh. It
seems to turn the `asprintf` symbol into a macro when using `-O2`
`-D_FORTIFY_SOURCE=2` + `#include includes.h`.

More detail here: https://github.com/spack/spack/issues/33131

```
/opt/spack/lib/spack/env/clang/clang -g -O2 -pipe
-Wunknown-warning-option -Qunused-arguments -Wall -Wpointer-arith
-Wuninitialized -Wsign-compare -Wformat-security
-Wsizeof-pointer-memaccess -Wno-pointer-sign -Wno-unused-result
-Wmisleading-indentation -Wbitwise-instead-of-logical
-fno-strict-aliasing -mretpoline -D_FORTIFY_SOURCE=2 -ftrapv
-fzero-call-used-regs=all -fno-builtin-memset -fstack-protector-strong 
 -fPIC -I. -I.. -I. -I./..  -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
-D_DEFAULT_SOURCE
-I/opt/install/linux-ubuntu18.04-x86_64/clang-15.0.0/krb5-1.19.3-riaeukuk7bbucxf5gmp6jeoh2ubhkrul/include
-I/opt/install/linux-ubuntu18.04-x86_64/clang-15.0.0/krb5-1.19.3-riaeukuk7bbucxf5gmp6jeoh2ubhkrul/include
-DHAVE_CONFIG_H -c bsd-asprintf.c


bsd-asprintf.c:86:5: error: expected parameter declarator
int asprintf(char **str, const char *fmt, ...)
    ^
/usr/include/x86_64-linux-gnu/bits/stdio2.h:199:24: note: expanded from
macro 'asprintf'
  __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, VA_ARGS)
                       ^
/usr/include/features.h:382:31: note: expanded from macro
'__USE_FORTIFY_LEVEL'
#  define __USE_FORTIFY_LEVEL 2
                              ^
bsd-asprintf.c:86:5: error: expected ')'
/usr/include/x86_64-linux-gnu/bits/stdio2.h:199:24: note: expanded from
macro 'asprintf'
  __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, VA_ARGS)
                       ^
/usr/include/features.h:382:31: note: expanded from macro
'__USE_FORTIFY_LEVEL'
#  define __USE_FORTIFY_LEVEL 2
                              ^
bsd-asprintf.c:86:5: note: to match this '('
/usr/include/x86_64-linux-gnu/bits/stdio2.h:199:18: note: expanded from
macro 'asprintf'
  __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, VA_ARGS)
                 ^
bsd-asprintf.c:86:5: error: conflicting types for '__asprintf_chk'
int asprintf(char **str, const char *fmt, ...)
    ^
/usr/include/x86_64-linux-gnu/bits/stdio2.h:199:3: note: expanded from
macro 'asprintf'
  __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, VA_ARGS)
  ^
/usr/include/x86_64-linux-gnu/bits/stdio2.h:158:12: note: previous
declaration is here
extern int __asprintf_chk (char **__restrict __ptr, int __flag,
           ^
bsd-asprintf.c:92:15: error: use of undeclared identifier 'fmt'
        va_start(ap, fmt);
                     ^
bsd-asprintf.c:93:23: error: use of undeclared identifier 'fmt'
        ret = vasprintf(str, fmt, ap);
                             ^
5 errors generated.
```

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list