public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/15512] New: __bswap_constant_16 not compiled when -Werror -Wsign-conversion is given
@ 2013-05-21 18:56 edjee at google dot com
2014-06-13 17:41 ` [Bug libc/15512] " fweimer at redhat dot com
0 siblings, 1 reply; 2+ messages in thread
From: edjee at google dot com @ 2013-05-21 18:56 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=15512
Bug #: 15512
Summary: __bswap_constant_16 not compiled when -Werror
-Wsign-conversion is given
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: unassigned@sourceware.org
ReportedBy: edjee@google.com
CC: drepper.fsp@gmail.com
Classification: Unclassified
(Filling a bug, following Andreas' suggestion)
I'm using gcc and glibc on 32bit LE ARM (But all the other platforms that use
the architecture-independent bit/byteswap.h may have similar issue).
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. In that
file, __bswap_constant_16 macro looks like this:
#define __bswap_constant_16(x) \
((unsigned short int)((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)))
It seems that ((x) >> 8) promotes the data to signed value, even if x is
unsigned. So (((x) >> 8) && 0xffu) seems to fail when -Werror -Wsign-conversion
is given.
All the architecture-specific versions of byteswap.h uses 0xff but this file
uses 0xffu. Is this intended?
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug libc/15512] __bswap_constant_16 not compiled when -Werror -Wsign-conversion is given
2013-05-21 18:56 [Bug libc/15512] New: __bswap_constant_16 not compiled when -Werror -Wsign-conversion is given edjee at google dot com
@ 2014-06-13 17:41 ` fweimer at redhat dot com
0 siblings, 0 replies; 2+ messages in thread
From: fweimer at redhat dot com @ 2014-06-13 17:41 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=15512
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Flags| |security-
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-06-13 17:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-21 18:56 [Bug libc/15512] New: __bswap_constant_16 not compiled when -Werror -Wsign-conversion is given edjee at google dot com
2014-06-13 17:41 ` [Bug libc/15512] " fweimer at redhat dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).