From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28631 invoked by alias); 12 May 2014 14:58:09 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 28195 invoked by uid 48); 12 May 2014 14:58:05 -0000 From: "hugh at mimosa dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.3.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hugh at mimosa dot com 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: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-05/txt/msg01037.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D39438 --- Comment #6 from D. Hugh Redelmeier --- Responding to Comment 5 by Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez: Thanks for looking at this. > Could you produce a complete testcase =3D=3D=3D /* compile with -c -Wformat -Werror=3Dformat-nonliteral */ #include 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); } =3D=3D=3D > The best would be to include only the definitions of the types that you n= eed > and declare as 'extern' library functions that you use to avoid inclu= ding 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 w= ould 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 o= wn, 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: 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: List-Archive: List-Post: List-Help: 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" 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: In-Reply-To: References: 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?id=61144 --- Comment #11 from Rich Felker --- Adding __attribute__((__used__)) to the static object suppresses the symptom in case that helps to isolate what's causing it.