From Bugzilla Helper: User-Agent: Mozilla/4.6 [en-gb]C-CCK-MCD NetscapeOnline.co.uk (Win98; I) Description of problem: Hello there, I have just tried to compile package gnuchess-5.02-9 from Redhat 8.0 I got the following messages from the compiler. cc: Warning: book.c, line 309: In this statement, this argument to printf and conversion specifier "%2.0f" combine integer and floating-point types. Behavior can be unpredictable. (outfloatint) cc: Warning: cmd.c, line 267: In this statement, this argument to sscanf is of "pointer to short" type and is not appropriate for the conversion specifier "%d". The value may overwrite other data or produce unexpected results. (inptrtype) cc: Warning: cmd.c, line 267: In this statement, this argument to sscanf is of "pointer to short" type and is not appropriate for the conversion specifier "%d". The value may overwrite other data or produce unexpected results. (inptrtype) cc: Warning: cmd.c, line 397: In this statement, this argument to printf and conversion specifier "%.2f" combine integer and floating-point types. Behavior can be unpredictable. (outfloatint) cc: Warning: iterate.c, line 98: In this statement, this argument to printf is of "float" type and is not appropriate for the conversion specifier "%s". The value will be formatted in an unintended manner. (outstringtype) cc: Warning: iterate.c, line 98: In this statement, the number of conversion specifiers to printf exceeds the number of values to be converted. Conversion specifiers from "%6.2f" onward will process meaningless and perhaps invalid data. (outtoofew) cc: Info: players.c, line 192: In this statement, an array is being accessed outside the bounds specified for the array type. (subscrbounds) Here is an untested patch to shut up the compiler. ./src/book.c.old ./src/book.c *** ./src/book.c.old Sun Dec 15 10:38:59 2002 --- ./src/book.c Sun Dec 15 10:39:56 2002 *************** *** 306,312 **** tot = r[matches[k]].wins+r[matches[k]].draws+r[matches[k]].losses; if (tot != 0) printf("B p=%2.0f\n", ! 100*(r[matches[k]].wins+r[matches[k]].draws)/tot); else printf("p=NO EXPERIENCES\n"); } --- 306,312 ---- tot = r[matches[k]].wins+r[matches[k]].draws+r[matches[k]].losses; if (tot != 0) printf("B p=%2.0f\n", ! (float) 100*(r[matches[k]].wins+r[matches[k]].draws)/tot); else printf("p=NO EXPERIENCES\n"); } ./src/cmd.c.old ./src/cmd.c *** ./src/cmd.c.old Sun Dec 15 10:40:11 2002 --- ./src/cmd.c Sun Dec 15 10:43:43 2002 *************** *** 264,270 **** } } else if (strcmp (cmd, "rating") == 0) { ! sscanf(inputstr,"%d %d",&myrating,&opprating); fprintf(ofp,"my rating = %d, opponent rating = %d\n",myrating,opprating); /* Change randomness of book based on opponent rating. */ /* Basically we play narrower book the higher the opponent */ --- 264,270 ---- } } else if (strcmp (cmd, "rating") == 0) { ! sscanf(inputstr,"%hd %hd",&myrating,&opprating); fprintf(ofp,"my rating = %d, opponent rating = %d\n",myrating,opprating); /* Change randomness of book based on opponent rating. */ /* Basically we play narrower book the higher the opponent */ *************** *** 394,400 **** if (!(flags & XBOARD)) { printf ("Time Control: %d moves in %.2f secs\n", MoveLimit[white], TimeLimit[white]); ! printf("Fischer increment of %.2f seconds\n",TCinc); } } } --- 394,400 ---- if (!(flags & XBOARD)) { printf ("Time Control: %d moves in %.2f secs\n", MoveLimit[white], TimeLimit[white]); ! printf("Fischer increment of %.2f seconds\n", (float) TCinc); } } } ./src/iterate.c.old ./src/iterate.c ./src/players.c.old ./src/players.c *** ./src/players.c.old Sun Dec 15 10:45:14 2002 --- ./src/players.c Sun Dec 15 10:46:07 2002 *************** *** 189,195 **** *p++; } while (*p != '\0'); *x = '\000'; ! memset(playerdb,0,sizeof(playerdb[MAXPLAYERS])); DBReadPlayer (); index = DBSearchPlayer (lname); if (index == -1) { --- 189,195 ---- *p++; } while (*p != '\0'); *x = '\000'; ! memset( playerdb, 0, sizeof(playerdb)); DBReadPlayer (); index = DBSearchPlayer (lname); if (index == -1) { Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1. compile with Compaq C compiler 2. 3. Additional info: Use of Compaq C compiler not significant. Any C compiler that checks printf'scanf parameter lists will produce similar messages.
I'm only interested in gcc errors/messages, sorry. I recompiled gnuchess to check for problems, but didn't get any of your messages. This needs to be fixed upstream: bug-gnu-chess
>I'm only interested in gcc errors/messages, sorry. That's a very short sighted policy. You would be very well advised to look at any warning any compiler produces, especially compilers which have better checking. >I recompiled gnuchess to check for >problems, but didn't get any of your messages. Suggest try using the -Wall flag on gcc. >This needs to be fixed upstream: bug-gnu-chess I've found some problems, I've provided a patch, what's so hard about you applying the patch and fixing it ?
no problem at all even with -Wall: .... gcc -DHAVE_CONFIG_H -I. -I. -I. -pthread -O2 -Wall -c `test -f book.c || echo './'`book.c source='cmd.c' object='cmd.o' libtool=no \ depfile='.deps/cmd.Po' tmpdepfile='.deps/cmd.TPo' \ depmode=gcc3 /bin/sh ../depcomp \ gcc -DHAVE_CONFIG_H -I. -I. -I. -pthread -O2 -Wall -c `test -f cmd.c || echo './'`cmd.c .... I won't add patches for compilers which aren't part of our distribution unless the same bugs show up with our compiler. Please report this bug to the gnuchess maintainers, they will be happy about your patch and it will be fixed in their next release. That one will be picked up by all distributions and the problem is gone for all of them. I'm not rejecting your patch because I don't like it, it's just because I don't need it for Red Hat Linux and fixing the problem upstream is the better way to handle this.