[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#32189: 27.0.50; GCC 7 warning due to -Wformat-truncation=2

From: Eli Zaretskii
Subject: bug#32189: 27.0.50; GCC 7 warning due to -Wformat-truncation=2
Date: Fri, 20 Jul 2018 09:56:25 +0300

> Cc: address@hidden, address@hidden
> From: Paul Eggert <address@hidden>
> 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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]