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: Edward Jee <edjee at google dot com>
- To: Andreas Jaeger <aj at suse dot com>
- Cc: libc-help <libc-help at sourceware dot org>
- Date: Tue, 21 May 2013 00:22:27 -0700
- 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> <519B1ACE dot 4090608 at suse dot com>
Hi Andreas, thanks a lot for your response.
That change (BZ #12194) uses 0xff for sysdeps/s390/bits/byteswap.h .
But uses 0xffu bits/byteswap.h .
In my platform I use bits/byteswap.h . And, it seems that ((x) >> 8)
promotes the data to signed value. So (((x) >> 8) && 0xffu) seems to
fail when -Werror -Wsign-conversion .
I can't understand very well why bits/byteswap.h uses 0xffu , while
most of the other platform-dependent byteswap.h use 0xff.
Thanks
On Mon, May 20, 2013 at 11:57 PM, Andreas Jaeger <aj@suse.com> wrote:
> 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
--
Edward Hyun-koo Jee (ìíê)
Software Engineer, Google Inc.