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.