This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Compiler warning: type punned pointers - patch required?
- From: "Uwe Kindler" <uwe_kindler at web dot de>
- To: <ecos-patches at sources dot redhat dot com>
- Date: Fri, 20 Feb 2004 10:54:38 +0100
- Subject: Compiler warning: type punned pointers - patch required?
Hello,
I currently finish the Renesas EDOSK-2674 port an try to remove all warnings
from build process.
I use the a h8300-elf toolchain based on gcc-3.3 branch snapshot dated 15th
December 2003. During RedBoot build I get a lot of these warnings:
/ecos-d/ecos/packages/redboot/current/src/fconfig.c:469:
warning:dereferencing type-punned pointer will break strict-aliasing rules
/ecos-d/ecos/packages/redboot/current/src/fconfig.c:471:
warning:dereferencing type-punned pointer will break strict-aliasing rules
/ecos-d/ecos/packages/redboot/current/src/fconfig.c:473:
warning:dereferencing type-punned pointer will break strict-aliasing rules
/ecos-d/ecos/packages/redboot/current/src/fconfig.c:475:
warning:dereferencing type-punned pointer will break strict-aliasing rules
/ecos-d/ecos/packages/redboot/current/src/fconfig.c:477:
warning:dereferencing type-punned pointer will break strict-aliasing rules
Other files like load.c, mfill.c also cause such warnings. If I inspect
thefconfig.c source wich caused these warnings, then I can see that
functions are called this way:
init_opts(&opts[0], 'l', false, OPTION_ARG_TYPE_FLG,
(void **)&list_only, (bool *)0, "list configuration only");
but they are defined this way:
void
init_opts(struct option_info *opts, char flag, bool takes_arg,
int arg_type, void *arg, bool *arg_set, char *name);
Therefore the cast of (void **)&list_only for the void *arg function
argument causes the warning. If I change the function call this way:
init_opts(&opts[0], 'l', false, OPTION_ARG_TYPE_FLG,
(void *)&list_only, (bool *)0, "list configuration only");
the warnings go away.
So my question is: Is there a special reason for casting to void ** when
void * is required. If you would say this is a bug then I would supply a
patch which removes all theses warnings.
Regards, Uwe