warning: value computed is not used
Byron Stanoszek
gandalf@winds.org
Thu Sep 28 19:13:00 GMT 2000
While using the latest snapshot (20000928), I came across this error in much of
my code. It results from a #define ({ result; }) macro where the result is
[optionally], but not always, used. Line 19, below.
---
warning.c:
#include <stdlib.h>
#include <string.h>
/* like strncpy but doesn't pad with zeroes. n=buffer size instead of siz-1 */
#define strmaxcpy(d, s, n) ({ char *_d=d; int _n=n; \
if(_n > 0 && !memccpy(_d, s, 0, _n)) \
_d[_n-1]='\0'; _d; })
int main(int argc, char *argv[])
{
char buf[256], buf2[256];
char *dest;
/* produces no warning */
dest = strmaxcpy(buf, argv[0], 256);
/* produces warning */
strmaxcpy(buf2, argv[0], 256); /* line 19 */
exit(0);
}
root:~> gcc -Wall -O3 warning.c -c
warning.c: In function `main':
warning.c:19: warning: value computed is not used
warning.c:22: warning: control reaches end of non-void function
---
Also, the warning on line 22 hasn't come up before. Has exit() been dropped
from the list of built-in functions?
--
Byron Stanoszek Ph: (330) 644-3059
Systems Programmer Fax: (330) 644-8110
Commercial Timesharing Inc. Email: bstanoszek@comtime.com
More information about the Gcc
mailing list