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

Bug#526620: False positive from -Wreturn-type



Package: gcc-4.4
Version: 4.4.0-1

I have the following code:

static void *queue_thread(void attribute((unused)) *arg) {
  struct packet *p;

  for(;;) {
    /* Get the next packet */
    pthread_mutex_lock(&receive_lock);
    while(!received_packets) {
      pthread_cond_wait(&receive_cond, &receive_lock);
    }
    p = received_packets;
    received_packets = p->next;
    if(!received_packets)
      received_tail = &received_packets;
    --nreceived;
    pthread_mutex_unlock(&receive_lock);
    /* Add it to the heap */
    pthread_mutex_lock(&lock);
    pheap_insert(&packets, p);
    nsamples += p->nsamples;
    pthread_cond_broadcast(&cond);
    pthread_mutex_unlock(&lock);
  }
}

This function's return type is required to be 'void *' because it is passed to pthread_create(); but it never actually returns. However, gcc-4.4 -Wall generates the following warning for it:

playrtp.c: In function ‘queue_thread’:
playrtp.c:327: error: no return statement in function returning non-void

(It's shown here as an error since I always use -Werror, because many warnings actually indicate problems that really must be fixed.)

GCC 4.3 generates no such warning.

The underlying warning is -Wreturn-type, which is enabled by -Wall. The documentation for this function hasn't changed since GCC 4.3 as far as I can see but evidently the behavior has - it now has a false positive which it previously did not.

I'd rather not just disable the warning from configure since it also can detect real errors.

ttfn/rjk




Reply to: