public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "tavianator at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/61118] New: Spurious -Wclobbered warning generated by gcc 4.9.0 for pthread_cleanup_push
Date: Thu, 08 May 2014 20:45:00 -0000	[thread overview]
Message-ID: <bug-61118-4@http.gcc.gnu.org/bugzilla/> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 4176 bytes --]

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61118

            Bug ID: 61118
           Summary: Spurious -Wclobbered warning generated by gcc 4.9.0
                    for pthread_cleanup_push
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tavianator at gmail dot com

Created attachment 32762
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32762&action=edit
Source file

On gcc 4.9.0 (but not on 4.8.2 or earlier), the attached code gives two
spurious warnings:

$ gcc -std=gnu99 -Wclobbered -O2 -c clobber_warning.c -pthread -save-temps
clobber_warning.c: In function ‘dmnsn_future_wait’:
clobber_warning.c:23:54: warning: variable ‘__cancel_routine’ might be
clobbered by ‘longjmp’ or ‘vfork’ [-Wclobbered]
     pthread_cleanup_push(cleanup_fn, &future->mutex);
                                                      ^
clobber_warning.c:23:103: warning: variable ‘__cancel_arg’ might be clobbered
by ‘longjmp’ or ‘vfork’ [-Wclobbered]
     pthread_cleanup_push(cleanup_fn, &future->mutex);

Those variables come from the expansion of the pthread_cleanup_{push,pop}
macros, which look like this (reformatted a little):

do {
  __pthread_unwind_buf_t __cancel_buf;
  void (*__cancel_routine) (void *) = (cleanup_fn);
  void *__cancel_arg = (&future->mutex);
  int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *)
__cancel_buf.__cancel_jmp_buf, 0);
  if (__builtin_expect ((__not_first_call), 0)) {
    __cancel_routine (__cancel_arg);
    __pthread_unwind_next (&__cancel_buf);
  }
  __pthread_register_cancel (&__cancel_buf);
  do {;
    pthread_cond_wait(&future->cond, &future->mutex);
    do { } while (0);
  } while (0);
  __pthread_unregister_cancel (&__cancel_buf);
  if (0)
    __cancel_routine (__cancel_arg);
} while (0);

The __cancel_routine and __cancel_arg variables are never modified, so I don't
see how they can be clobbered.
>From gcc-bugs-return-451055-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu May 08 20:46:14 2014
Return-Path: <gcc-bugs-return-451055-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 16130 invoked by alias); 8 May 2014 20:46:14 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 16097 invoked by uid 48); 8 May 2014 20:46:11 -0000
From: "tavianator at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/61118] Spurious -Wclobbered warning generated by gcc 4.9.0 for pthread_cleanup_push
Date: Thu, 08 May 2014 20:46: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.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: tavianator at gmail 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: attachments.created
Message-ID: <bug-61118-4-uSoq9zw6jJ@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-61118-4@http.gcc.gnu.org/bugzilla/>
References: <bug-61118-4@http.gcc.gnu.org/bugzilla/>
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/msg00747.txt.bz2
Content-length: 240

http://gcc.gnu.org/bugzilla/show_bug.cgi?ida118

--- Comment #1 from Tavian Barnes <tavianator at gmail dot com> ---
Created attachment 32763
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id2763&actioníit
Preprocessed source file


             reply	other threads:[~2014-05-08 20:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-08 20:45 tavianator at gmail dot com [this message]
2015-04-02  5:48 ` [Bug middle-end/61118] " douzzer at mega dot nu
2015-09-10 10:17 ` lambertarthur22 at gmail dot com
2021-05-14  9:47 ` [Bug middle-end/61118] [9/10/11/12 Regression] Indirect call generated for pthread_cleanup_push with constant cleanup function jakub at gcc dot gnu.org
2021-06-01  8:06 ` rguenth at gcc dot gnu.org
2022-05-27  9:35 ` [Bug middle-end/61118] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:30 ` jakub at gcc dot gnu.org
2023-07-07 10:30 ` [Bug middle-end/61118] [11/12/13/14 " rguenth at gcc dot gnu.org
2024-04-29  4:26 ` [Bug middle-end/61118] [11/12/13/14/15 " eggert at cs dot ucla.edu
2024-04-29  4:41 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-61118-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).