[Top][All Lists]

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

Re: [bug-diffutils] [PATCH] diff: avoid possible longjmp-triggered misbe

From: Paul Eggert
Subject: Re: [bug-diffutils] [PATCH] diff: avoid possible longjmp-triggered misbehavior
Date: Thu, 30 Aug 2012 07:55:51 -0700
User-agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120714 Thunderbird/14.0

On 08/28/2012 02:08 AM, Jim Meyering wrote:
> It seems legit, but perhaps it should be complaining about "match"
> rather than "file".

I don't see why it's legit.  Even if longjmp trashes
the value of 'match', the code right after the longjmp
immediately sets 'match' (there's a comment to the code
to that effect).

This bogus warning, along with the seemingly random variable
name that it mentions, may be the symptom of a deeper
problem in GCC, one that causes GCC to generate incorrect code,
so it's probably worth filing a GCC bug report.

For now I pushed this further patch into diffutils:

>From e1c27502ee286392ef2be93af752a51574930038 Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Thu, 30 Aug 2012 07:52:22 -0700
Subject: [PATCH] diff: silence GCC warning instead of slowing down

* src/dir.c (find_dir_file_pathname): Use 'IF_LINT (volatile)' to
silence the gcc warning, rather than using 'volatile', as the
warning appears to be bogus.
 src/dir.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/dir.c b/src/dir.c
index a2f6bba..530807e 100644
--- a/src/dir.c
+++ b/src/dir.c
@@ -323,8 +323,13 @@ dir_loop (struct comparison const *cmp, int i)
 char *
 find_dir_file_pathname (char const *dir, char const *file)
+  /* The 'IF_LINT (volatile)' works around what appears to be a bug in
+     gcc 4.8.0 20120825; see
+     <http://lists.gnu.org/archive/html/bug-diffutils/2012-08/msg00007.html>.
+     */
+  char const * IF_LINT (volatile) match = file;
   char *val;
-  char const *volatile match = file;
   struct dirdata dirdata;
   dirdata.names = NULL;
   dirdata.data = NULL;

reply via email to

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