Cast alignment warnings
Julien ÉLIE
julien at trigofacile.com
Mon Aug 1 18:33:03 UTC 2011
Hi all,
On a Debian sparc64 server (TI UltraSparc IIe Hummingbird), I encounter cast alignment errors:
/home/iulius/autobuild/bin/gcc-core-4.6.1/bin/gcc -g -O2 -DDEBUG=1 -Wall -W -Wendif-labels -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Werror -g -O2 -I../include -c network.c
network.c: In function ‘network_sockaddr_sprint’:
network.c:611:15: error: cast increases required alignment of target type [-Werror=cast-align]
network.c: In function ‘network_sockaddr_equal’:
network.c:629:36: error: cast increases required alignment of target type [-Werror=cast-align]
network.c:630:36: error: cast increases required alignment of target type [-Werror=cast-align]
network.c: In function ‘network_sockaddr_port’:
network.c:685:15: error: cast increases required alignment of target type [-Werror=cast-align]
cc1: all warnings being treated as errors
/home/iulius/autobuild/bin/gcc-core-4.6.1/bin/gcc -g -O2 -DDEBUG=1 -Wall -W -Wendif-labels -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Werror -g -O2 -I../include -c -o rc.o rc.c
rc.c: In function ‘GoodIdent’:
rc.c:161:10: error: cast increases required alignment of target type [-Werror=cast-align]
rc.c:162:17: error: cast increases required alignment of target type [-Werror=cast-align]
rc.c:163:3: error: cast increases required alignment of target type [-Werror=cast-align]
rc.c:164:3: error: cast increases required alignment of target type [-Werror=cast-align]
gcc -g -O2 -DDEBUG=1 -Wall -W -Wendif-labels -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Werror -I../include -I. -DTESTING -c -o lib/getaddrinfo.o ../lib/getaddrinfo.c
cc1: warnings being treated as errors
../lib/getaddrinfo.c: In function ‘gai_addrinfo_new’:
../lib/getaddrinfo.c:182: error: cast increases required alignment of target type
../lib/getaddrinfo.c:183: error: cast increases required alignment of target type
../lib/getaddrinfo.c:184: error: cast increases required alignment of target type
gcc -g -O2 -DDEBUG=1 -Wall -W -Wendif-labels -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Werror -I../include -I. -DTESTING -c -o lib/getnameinfo.o ../lib/getnameinfo.c
cc1: warnings being treated as errors
../lib/getnameinfo.c: In function ‘test_getnameinfo’:
../lib/getnameinfo.c:150: error: cast increases required alignment of target type
[...]
It concerns casts from sockaddr to sockaddr_in.
>From "bits/socket.h":
/* Structure describing a generic socket address. */
struct sockaddr
{
__SOCKADDR_COMMON (sa_); /* Common data: address family and length. */
char sa_data[14]; /* Address data. */
};
>From "netinet/in.h":
typedef uint16_t in_port_t;
typedef uint32_t in_addr_t;
struct in_addr
{
in_addr_t s_addr;
};
/* Structure describing an Internet socket address. */
struct sockaddr_in
{
__SOCKADDR_COMMON (sin_);
in_port_t sin_port; /* Port number. */
struct in_addr sin_addr; /* Internet address. */
/* Pad to size of `struct sockaddr'. */
unsigned char sin_zero[sizeof (struct sockaddr) -
__SOCKADDR_COMMON_SIZE -
sizeof (in_port_t) -
sizeof (struct in_addr)];
};
Another similar issue:
/home/iulius/autobuild/bin/gcc-core-4.6.1/bin/gcc -g -O2 -DDEBUG=1 -Wall -W -Wendif-labels -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Werror -g -O2 -I../include -I. -c -o buffindexed/buffindexed.o buffindexed/buffindexed.c
buffindexed/buffindexed.c: In function ‘buffindexed_open’:
buffindexed/buffindexed.c:1050:20: error: cast increases required alignment of target type [-Werror=cast-align]
buffindexed/buffindexed.c: In function ‘GROUPremapifneeded’:
buffindexed/buffindexed.c:1205:18: error: cast increases required alignment of target type [-Werror=cast-align]
buffindexed/buffindexed.c: In function ‘GROUPexpand’:
buffindexed/buffindexed.c:1240:18: error: cast increases required alignment of target type [-Werror=cast-align]
buffindexed/buffindexed.c: In function ‘ovgroupmmap’:
buffindexed/buffindexed.c:1666:15: error: cast increases required alignment of target type [-Werror=cast-align]
cc1: all warnings being treated as errors
It concerns:
GROUPentries = (GROUPENTRY *)((char *)GROUPheader + sizeof(GROUPHEADER));
/home/iulius/autobuild/bin/gcc-core-4.6.1/bin/gcc -g -O2 -DDEBUG=1 -Wall -W -Wendif-labels -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Werror -g -O2 -I../include -I. -c -o timecaf/timecaf.o timecaf/timecaf.c
timecaf/timecaf.c: In function ‘PathNumToToken’:
timecaf/timecaf.c:193:51: error: cast increases required alignment of target type [-Werror=cast-align]
and
timehash/timehash.c:123:16: error: cast increases required alignment of target type [-Werror=cast-align]
It concerns:
STORAGECLASS class;
n = sscanf(path, "timecaf-%02x/%02x/%04x.CF", (unsigned int *)&class, &t1, &t2);
gcc -g -O2 -DDEBUG=1 -Wall -W -Wendif-labels -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Werror -g -O2 -I../include -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/home/iulius/autobuild/bin/perl-5.14.1/lib/5.14.1/sparc64-linux/CORE -Wno-extra -c perl.c
cc1: warnings being treated as errors
It concerns:
p = HePV(scan, len);
I admit I am a bit puzzled.
How are such alignment errors supposed to be fixed?
--
Julien ÉLIE
« Un ami fidèle qui parle très bien votre langue et toutes les
langues vivantes : le latin, le grec, le celte, etc. » (Astérix)
More information about the inn-workers
mailing list