User account creation filtered due to spam.

Bug 48544 - "might be clobbered by ‘longjmp’" diagnostic for unmodified variable
Summary: "might be clobbered by ‘longjmp’" diagnostic for unmodified variable
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2011-04-10 19:14 UTC by Alexandre Duret-Lutz
Modified: 2015-08-20 11:22 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
preprocessed input (612 bytes, text/plain)
2011-04-10 19:14 UTC, Alexandre Duret-Lutz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexandre Duret-Lutz 2011-04-10 19:14:59 UTC
Created attachment 23939 [details]
preprocessed input

% uname -a
Linux hush 2.6.32-5-amd64 #1 SMP Wed Jan 12 03:40:32 UTC 2011 x86_64 GNU/Linux
% gcc-4.6 --version
gcc-4.6 (Debian 4.6.0-2) 4.6.1 20110329 (prerelease)
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% cat foo.c
#include <setjmp.h>

jmp_buf env;
void foo(int);

int bar(int r, int var)
{
  if (var)
    return r;
  if (setjmp(env) == 0)
    foo(r);
  return 0;
}
% gcc-4.6 -Wall -Wextra -O2 -c foo.c
foo.c: In function ‘bar’:
foo.c:6:13: warning: argument ‘r’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Wclobbered]

If I understand this message correctly, GCC is warning me that "r" might be reset to the value it had before calling setjmp().  However, I never changed the value of "r", so I don't think this warning should be emitted.

Note that removing the "if (var) return r;" lines makes the warning go away.
Comment 1 Alexandre Duret-Lutz 2015-08-20 11:22:25 UTC
This works OK with 4.8 and 5.1, so not an issue anymore as far as I'm concerned.
(Might be related to #48968 which is reported as "half-fixed" -- I haven't tried.)