This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: __bswap_constant_16 not compiled when -Werror -Wsign-conversion is given (32bit LE ARM)
- From: Andreas Jaeger <aj at suse dot com>
- To: libc-help at sourceware dot org, edjee at google dot com
- Date: Tue, 21 May 2013 08:57:18 +0200
- Subject: Re: __bswap_constant_16 not compiled when -Werror -Wsign-conversion is given (32bit LE ARM)
- References: <CACBWV96dWwchoXBWMrM994RNL09TP+R4pJUujqSZtBdDWqY=yQ at mail dot gmail dot com>
On 05/21/2013 01:14 AM, Edward Jee wrote:
Hi, may I ask a question?
I'm using gcc and glibc on 32bit LE ARM. And I found that the
following code is not compiled, if I give -Werror -Wsign-conversion
arguments to gcc.
#include <stdio.h>
#include <byteswap.h>
int main(int argc, char *argv[]) {
unsigned short int x = 0xbeef;
printf("bswap_16(0x%x)=0x%x\n", x, bswap_16(x));
return 0;
}
I saw compilation error "conversion to 'unsigned int' from 'int' may
change the sign of the result".
It looks like that a similar issue has been solved for x86 by
http://sourceware.org/git/?p=glibc.git;a=commit;h=69da074d7adfab7b57004a0dea9403a928e310a5
.
But the architecture-independent bit/byteswap.h has not been modified
(I'm using that file).
Could someone tell me why this modification is not done for the
architecture-independent bit/byteswap.h ? Am I doing something wrong?
Which glibc version are you using? It was fixed with this commit,
Andreas
2012-06-21 Andreas Jaeger <aj@suse.de>
[BZ #12194]
* sysdeps/s390/bits/byteswap-16.h (__bswap_16): Avoid -Wconversion
warning.
* sysdeps/s390/bits/byteswap.h (__bswap_constant_16): Likewise.
* bits/byteswap-16.h (__bswap_16): Likewise.
* bits/byteswap.h (__bswap_constant_16): Likewise.
--
Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126