From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#32189: 27.0.50; GCC 7 warning due to -Wformat-truncation=2 Date: Fri, 20 Jul 2018 09:56:25 +0300 Message-ID: <83y3e61jl2.fsf@gnu.org> References: <031d18cf-e661-6dea-8882-38d75924d0d4@cornell.edu> <83601c4m37.fsf@gnu.org> <83in5b2w1q.fsf@gnu.org> <83d0vj2tu2.fsf@gnu.org> <6642c8ac-55ff-ca2b-0141-a26b69d082ad@cs.ucla.edu> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1532069713 3490 195.159.176.226 (20 Jul 2018 06:55:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 20 Jul 2018 06:55:13 +0000 (UTC) Cc: p.stephani2@gmail.com, 32189@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 20 08:55:08 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fgPJk-0000om-0g for geb-bug-gnu-emacs@m.gmane.org; Fri, 20 Jul 2018 08:55:08 +0200 Original-Received: from localhost ([::1]:46699 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fgPLq-0003SD-TV for geb-bug-gnu-emacs@m.gmane.org; Fri, 20 Jul 2018 02:57:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50479) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fgPLd-0003Rr-Qp for bug-gnu-emacs@gnu.org; Fri, 20 Jul 2018 02:57:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fgPLa-0008Af-Kf for bug-gnu-emacs@gnu.org; Fri, 20 Jul 2018 02:57:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:43723) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fgPLa-0008AV-GX for bug-gnu-emacs@gnu.org; Fri, 20 Jul 2018 02:57:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fgPLa-0002uK-4z for bug-gnu-emacs@gnu.org; Fri, 20 Jul 2018 02:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 20 Jul 2018 06:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32189 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 32189-submit@debbugs.gnu.org id=B32189.153206979711142 (code B ref 32189); Fri, 20 Jul 2018 06:57:02 +0000 Original-Received: (at 32189) by debbugs.gnu.org; 20 Jul 2018 06:56:37 +0000 Original-Received: from localhost ([127.0.0.1]:48741 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fgPLB-0002te-5X for submit@debbugs.gnu.org; Fri, 20 Jul 2018 02:56:37 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:59407) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fgPL9-0002tQ-9O for 32189@debbugs.gnu.org; Fri, 20 Jul 2018 02:56:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fgPL0-0007vO-Sr for 32189@debbugs.gnu.org; Fri, 20 Jul 2018 02:56:30 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:42188) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fgPL0-0007vK-Ni; Fri, 20 Jul 2018 02:56:26 -0400 Original-Received: from [176.228.60.248] (port=2210 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fgPKz-0005QR-FJ; Fri, 20 Jul 2018 02:56:26 -0400 In-reply-to: <6642c8ac-55ff-ca2b-0141-a26b69d082ad@cs.ucla.edu> (message from Paul Eggert on Thu, 19 Jul 2018 16:19:38 -0700) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:148705 Archived-At: > Cc: p.stephani2@gmail.com, 32189@debbugs.gnu.org > From: Paul Eggert > Date: Thu, 19 Jul 2018 16:19:38 -0700 > > Let's continue using -Wformat-truncation=2 since I recall it finding real bugs > in Emacs in the past, and there's a better fix for this particular problem. > > Some background. Generally I don't worry too much about warnings from older > compilers, since one can just compile with --disable-gcc-warnings if the > compiler is too old. Well, GCC 7 is not exactly "old". GCC 8 was released just a couple of months ago, and GCC 7.3 is from January this year. If you are saying that this switch does a better job in later versions of GCC, maybe we should disable it for GCC 7 alone? > Second, the code in question uses snprintf followed by build_string, and can be > simplified by using vformat_string instead. That would avoid the warnings and > should make the code more reliable. Something like the attached patch, say. I > haven't tested it since I don't use MS-Windows. Let's use something like this > rather than shutting off the warnings. Works for me (although vformat_string does exactly what a call to snprintf does, just with a larger buffer). Ken, could you please check if this works in the Cygwin build? If so, I think we are good with this change. And I was wrong: it should go to the master branch, not to emacs-26.