This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

warning: value computed is not used


In the latest gcc snapshot (2.97 20001008), these warnings persist:

root:~> /dsk0/src/egcs/obj/gcc/xgcc -B/dsk0/src/egcs/obj/gcc/
-B/usr/i686-pc-linux-gnu/bin/ -B/usr/i686-pc-linux-gnu/lib/ -isystem
/usr/i686-pc-linux-gnu/include warning.c -Wall -c
warning.c: In function `main':
warning.c:20: warning: implicit declaration of function `exit'
warning.c:18: warning: value computed is not used
root:~> cat warning.c
#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 because the return value is optionally used */
  dest = strmaxcpy(buf, argv[0], 256);

  /* produces warning */
  strmaxcpy(buf2, argv[0], 256);  /* line 18 */

  exit(0);
}

I mentioned this on the list a couple of weeks ago, but had received no
response. A snapshot from early September did not mention these warnings,
but 20000924 did also.

I was wondering if you could add a testcase for the unused variable in ({ })
macros, and/or potentially fix the problem. I don't know enough about how
stmt.c works personally or I probably would have submitted a patch already.

The other one is about exit(). I assume it's not a built-in gcc function
anymore, which is why it's giving me a warning without the declaration.
Can any of you shed some light on this one?

Regards,
 Byron

-- 
Byron Stanoszek                         Ph: (330) 644-3059
Systems Programmer                      Fax: (330) 644-8110
Commercial Timesharing Inc.             Email: bstanoszek@comtime.com



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]