public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hugh at mimosa dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/39438] Can't compile a wrapper around strftime with -Werror=format-nonliteral Date: Mon, 12 May 2014 14:58:00 -0000 [thread overview] Message-ID: <bug-39438-4-DBNsVJb5jq@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-39438-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39438 --- Comment #6 from D. Hugh Redelmeier <hugh at mimosa dot com> --- Responding to Comment 5 by Manuel López-Ibáñez: Thanks for looking at this. > Could you produce a complete testcase === /* compile with -c -Wformat -Werror=format-nonliteral */ #include <time.h> extern void prettynow(char *buf, size_t buflen, const char *fmt, struct tm *t) __attribute__ ((format (__strftime__, 3, 0))); void prettynow(char *buf, size_t buflen, const char *fmt, struct tm *t) { strftime(buf, buflen, fmt, t); } === > The best would be to include only the definitions of the types that you need > and declare as 'extern' library functions that you use to avoid including headers. I didn't do this part. My excuses: the type declarations are not portable but the example should be; the solution might be in fixing headers; this way is shorter too. > If you can produce another similar example that works with printf, that would also help. I don't think that printf is similar enough. A strftime format doesn't interact with varargs in a complex and problematic way. A string, on its own, is or is not a valid strftime format; a string is only a valid printf format when considered with the argument list. If an arg is marked as a const char * (i.e. unchanging) and has the strftime format attribute, it should be accepted as if it were a literal strftime argument. After all, the necessary checking would have been done at this routine's points of call. >From gcc-bugs-return-451346-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon May 12 15:16:33 2014 Return-Path: <gcc-bugs-return-451346-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org> Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 6668 invoked by alias); 12 May 2014 15:16:32 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: <gcc-bugs.gcc.gnu.org> List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/> List-Post: <mailto:gcc-bugs@gcc.gnu.org> List-Help: <mailto:gcc-bugs-help@gcc.gnu.org> Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 6624 invoked by uid 48); 12 May 2014 15:16:28 -0000 From: "bugdal at aerifal dot cx" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/61144] Invalid optimizations for extern vars with local weak definitions Date: Mon, 12 May 2014 15:16:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bugdal at aerifal dot cx X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: <bug-61144-4-PTSTSPdJbs@http.gcc.gnu.org/bugzilla/> In-Reply-To: <bug-61144-4@http.gcc.gnu.org/bugzilla/> References: <bug-61144-4@http.gcc.gnu.org/bugzilla/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-05/txt/msg01038.txt.bz2 Content-length: 242 http://gcc.gnu.org/bugzilla/show_bug.cgi?ida144 --- Comment #11 from Rich Felker <bugdal at aerifal dot cx> --- Adding __attribute__((__used__)) to the static object suppresses the symptom in case that helps to isolate what's causing it.
next prev parent reply other threads:[~2014-05-12 14:58 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-39438-4@http.gcc.gnu.org/bugzilla/> 2012-01-10 20:39 ` tss at iki dot fi 2014-05-10 16:47 ` hugh at mimosa dot com 2014-05-12 12:26 ` manu at gcc dot gnu.org 2014-05-12 14:58 ` hugh at mimosa dot com [this message] 2014-05-12 15:38 ` manu at gcc dot gnu.org 2014-05-12 15:52 ` manu at gcc dot gnu.org 2014-05-12 19:33 ` hugh at mimosa dot com 2015-02-27 16:43 ` manu at gcc dot gnu.org 2024-06-03 1:48 ` peter0x44 at disroot dot org 2009-03-11 22:57 [Bug c/39438] New: " 4tmuelle at informatik dot uni-hamburg dot de 2009-03-12 9:40 ` [Bug c/39438] " rguenth at gcc dot gnu dot org 2009-03-12 9:58 ` 4tmuelle at informatik dot uni-hamburg dot 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-39438-4-DBNsVJb5jq@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).