LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 23512 - Clang prints garbage in compile warning
Summary: Clang prints garbage in compile warning
Status: RESOLVED MOVED
Alias: None
Product: clang
Classification: Unclassified
Component: -New Bugs (show other bugs)
Version: 3.5
Hardware: PC FreeBSD
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-13 03:29 PDT by HPS
Modified: 2015-05-14 15:25 PDT (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments
Preprocessed file (311.21 KB, text/x-c)
2015-05-14 10:30 PDT, HPS
Details

Note You need to log in before you can comment on or make changes to this bug.
Description HPS 2015-05-13 03:29:32 PDT
Hi,

Clang prints garbage in one of its warnings:

> clang35 -v
clang version 3.5.1 (tags/RELEASE_351/final)
Target: x86_64-portbld-freebsd9.3
Thread model: posix

> bmake -m $PWD/share/mk CC=/usr/local/bin/clang35 LD=/usr/local/bin/ld buildkernel -DNO_CLEAN -DNO_KERNELDEPEND WERROR=""

/usr/img/freebsd/sys/modules/sppp/../../net/if_spppsubr.c:5372:15: warning: format specifies type 'unsigned char *' but the argument has
      ���������������`������������0������P����������

--HPS
Comment 1 Davide Italiano 2015-05-13 11:50:15 PDT
Can you please provide a minimal repro?
Comment 2 Davide Italiano 2015-05-13 11:50:51 PDT
Can you please provide a minimal repro?
Comment 3 HPS 2015-05-14 00:43:29 PDT
1) Checkout FreeBSD 11-current sources:

commit 5cfb29320af7efe68fe6aa83e89cc3650167c5f0
Author: ganbold <ganbold@FreeBSD.org>
Date:   Wed May 13 05:46:04 2015 +0000

    Delete cpu_do_powersave which is set but never used/tested
    serving no useful purpose.
    
3) Install clang35 from pkg under FreeBSD 9-stable.

4) In /etc/make.conf:

CC=/usr/local/bin/clang35
LD=/usr/local/bin/ld
COMPILER_TYPE=clang
COMPILER_VERSION=30500

5) cd /usr/img/freebsd/sys/modules/sppp
6) bmake -m /usr/img/freebsd/share/mk

Should reproduce.
Comment 4 Dimitry Andric 2015-05-14 09:51:18 PDT
"Minimal" in this context means a preprocessed .c or .cpp file, without any external dependencies.  Also, the exact command line flags used to invoke clang are almost always needed.
Comment 5 HPS 2015-05-14 10:30:02 PDT
Command line:

/usr/local/bin/clang35 -O2 -pipe -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc -fno-common -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign -fformat-extensions -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -mno-aes -mno-avx -std=iso9899:1999 -c if_spppsubr.c

See attached if_spppsubr.c

Thank you!

--HPS
Comment 6 HPS 2015-05-14 10:30:56 PDT
Created attachment 14327 [details]
Preprocessed file
Comment 7 Dimitry Andric 2015-05-14 11:10:31 PDT
Right, this is a bug in the FreeBSD-specific -fformat-extensions support, added in the lang/clang35 port.  This flag isn't supported by upstream clang, and has been replaced by the __format__(__freebsd_kprintf__, x, y) attribute in trunk.

For reference, a minimal example is:

void foo(int, const char *, ...) __attribute__((__format__(__printf__, 2, 3)));

void bar(const unsigned char *p, unsigned short len)
{
  foo(-1, " %*D", len, p, "-");
}

Let's move this bug over to the FreeBSD bug tracker:

https://bugs.freebsd.org/200193