This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
schedlock.c and thread-specific.c don't compile with gcc HEAD
- From: Michael Chastain <mec dot gnu at mindspring dot com>
- To: gdb at sources dot redhat dot com, dan at debian dot org, msnyder at redhat dot com
- Date: Sat, 31 Jul 2004 08:54:24 -0400
- Subject: schedlock.c and thread-specific.c don't compile with gcc HEAD
My latest spin blew up with the gcc-du-jour because of a new
gcc warning.
In gdb/testsuite/gdb.threads, schedlock.c and thread-specific.c
have code like this:
unsigned int args[NUM+1];
...
int *myp = &args[my_number];
/* Don't run forever. Run just short of it :) */
while (*myp > 0)
{
/* schedlock.exp: main loop. */
(*myp) ++;
}
gcc says:
/berman/migchain/source/gdb-6.1.1/gdb/testsuite/gdb.threads/schedlock.c: In function `thread_function':
/berman/migchain/source/gdb-6.1.1/gdb/testsuite/gdb.threads/schedlock.c:36: warning: pointer targets in initialization differ in signedness
and gdb_compile_pthreads chokes.
I remember that 'args' has to be unsigned for the script; that was a
problem a couple of releases ago. The simple ugly fix is:
int *myp = (int *) &args[my_number];
while (*myp > 0)
{
(*myp) ++;
}
But I don't like playing with the sign bit that way.
How about:
#include <limits.h>
unsigned int *myp = &args[my_number];
while (*myp < UINT_MAX)
{
(*myp) ++;
}
schedlock.c already includes <stdio.h>, <unistd.h>, <stdlib.h>,
and <pthread.h>, so the standard ansi header <limits.h> shouldn't
be a portability problem.
Also schedlock.c needs a copyright notice.
What do you think? I'll be happy to whip up a patch.
Michael C