Subject: Error cross-compiling lib/libc/rpc/svc_vc.c
To: None <port-vax@netbsd.org>
From: Tom Ivar Helbekkmo <tih@eunetnorge.no>
List: port-vax
Date: 12/07/2005 13:51:51
Building current CVS HEAD for VAX, on an i386, stops with error
messages for lib/libc/rpc/svc_vc.c:

/usr/src/lib/libc/rpc/svc_vc.c: In function `svc_vc_rendezvous_ops':
/usr/src/lib/libc/rpc/svc_vc.c:771: warning: cast discards qualifiers from pointer target type
/usr/src/lib/libc/rpc/svc_vc.c:773: warning: cast discards qualifiers from pointer target type
/usr/src/lib/libc/rpc/svc_vc.c:775: warning: cast discards qualifiers from pointer target type

This is reproducible using this source file:

#include <stdlib.h>
__dead void ofp(void) __attribute__((__noreturn__));
int main(int argc, char **argv) {
  int (*fp) (char *a, long b, int c);
  fp = (int (*) (char *, long, int)) ofp;
  return 0;
}

I compile the above, using the command line picked directly from the
build, thus:

/usr/local/tools/bin/vax--netbsdelf-gcc -O2 -pipe -Wall \
-Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
-Wno-sign-compare -Wno-traditional -Wno-uninitialized -Wreturn-type \
-Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Werror -D_LIBC \
-DLIBC_SCCS -DSYSLIBC_SCCS -D_REENTRANT -I/usr/src/lib/libc/include \
-I/usr/src/lib/libc -DHESIOD -DINET6 -DNLS -DYP \
-I. -D__DBINTERFACE_PRIVATE -DI18NMODULE_MAJOR=4 -DCITRUS \
-I/usr/src/sys -I/usr/src/lib/libc/stdlib -I/usr/src/libexec/ld.elf_so \
-I/usr/src/lib/libc/dlfcn -DCITRUS_ICONV -DWITH_RUNE \
-I/usr/src/lib/libc -DPOSIX_MISTAKE -DCOMPAT__RES -DPORTMAP \
-DFLOATING_POINT -DALL_STATE -DUSG_COMPAT -nostdinc -isystem \
/usr/local/arena/vax/usr/include -c example.c

The following warning is issued:

example.c: In function `main':
example.c:5: warning: cast discards qualifiers from pointer target type

Removing the "__attribute__((__noreturn__))" from the declaration of
the function ofp() gets rid of the warning, so the problem is, it
seems, to keep the cast from discarding this attribute.  I have tried
in many ways, but can't find the solution.

Anyone know how to fix this?

-tih
-- 
Don't ascribe to stupidity what can be adequately explained by ignorance.