public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "gcc@t-8ch.de" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/111513] New: Incorrect -Wformat-overflow warning when using UBSAN with gettext() Date: Thu, 21 Sep 2023 06:48:15 +0000 [thread overview] Message-ID: <bug-111513-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111513 Bug ID: 111513 Summary: Incorrect -Wformat-overflow warning when using UBSAN with gettext() Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: gcc@t-8ch.de CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org, jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at gcc dot gnu.org Target Milestone: --- Created attachment 55957 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55957&action=edit preprocessed source The test program below exhibits the following compiler warning: test.c: In function ‘main’: test.c:14:9: warning: null format string [-Wformat-overflow=] 14 | printf(gettext("foo %s\n"), "foo"); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test.c:14:9: warning: null format string [-Wformat-overflow=] /* test.c * * compile with: * gcc -Wall -fsanitize=undefined -O2 test.c */ #include <stdio.h> #include <libintl.h> int main(void) { FILE *out = stdout; fputs("\n", out); printf(gettext("foo %s\n"), "foo"); fputs("\n", out); } The warning can be "fixed" by *any* of the following steps: * remove any of the fputs() calls * inline the stdout parameter into the second fputs() call * build without optimizations * build without UBSAN Given the weirdness with regards to the fputs() calls I suspect the issue in GCC. $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /build/gcc/src/gcc/configure --enable-languages=ada,c,c++,d,fortran,go,lto,objc,obj-c++ --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.2.1 20230801 (GCC) glibc version: 2.38
next reply other threads:[~2023-09-21 6:48 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-09-21 6:48 gcc@t-8ch.de [this message] 2023-09-21 6:53 ` [Bug sanitizer/111513] " gcc@t-8ch.de 2023-09-21 7:15 ` [Bug tree-optimization/111513] " pinskia at gcc dot gnu.org 2023-09-21 7:20 ` pinskia at gcc dot gnu.org 2023-09-21 7:39 ` gcc@t-8ch.de
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-111513-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).