public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/12373] New: FD_SET macro gives warning with -Wconversion (with solution)
@ 2011-01-07  9:11 johan162 at gmail dot com
  2011-01-10  3:18 ` [Bug libc/12373] " drepper.fsp at gmail dot com
  2014-06-27 14:03 ` fweimer at redhat dot com
  0 siblings, 2 replies; 3+ messages in thread
From: johan162 at gmail dot com @ 2011-01-07  9:11 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12373

           Summary: FD_SET macro gives warning with -Wconversion (with
                    solution)
           Product: glibc
           Version: 2.11
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: johan162@gmail.com


It is not possible to compile the following code with gcc 4.4.1 and extra
warnings enabled without warning

#include <sys/select.h>
int main(void)
{
    fd_set fds;
    int    fd = 0;
    FD_ZERO(&fds);
    FD_SET(fd, &fds);
    return 0;
}

Compiling this:

gcc -Werror -Wconversion wtst.c
cc1: warnings being treated as errors
wtst.c: In function ‘main’:
wtst.c:8: error: conversion to ‘unsigned int’ from ‘int’ may change the sign of
the result
wtst.c:8: error: conversion to ‘unsigned int’ from ‘int’ may change the sign of
the result

gcc --version
gcc (SUSE Linux) 4.4.1 [gcc-4_4-branch revision 150839]

The problem stems from the inline assmebler expansion where there is type of fd
clashes with the return type of the sizeof() operator.

This can easily be corrected by changing the macro from the existing:

  __asm__ __volatile__ ("btsl %1,%0" : "=m" (((&fds)->__fds_bits)[((fd) / (8 *
sizeof (__fd_mask)))]) : "r" (((int) (fd)) % (8 * sizeof (__fd_mask))) :
"cc","memory");

to

  __asm__ __volatile__ ("btsl %1,%0" : "=m"
(((&fds)->__fds_bits)[((unsigned)(fd) / (8 * sizeof (__fd_mask)))]) : "r"
(((unsigned) (fd)) % (8 * sizeof (__fd_mask))) : "cc","memory");

-- 
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] 3+ messages in thread

* [Bug libc/12373] FD_SET macro gives warning with -Wconversion (with solution)
  2011-01-07  9:11 [Bug libc/12373] New: FD_SET macro gives warning with -Wconversion (with solution) johan162 at gmail dot com
@ 2011-01-10  3:18 ` drepper.fsp at gmail dot com
  2014-06-27 14:03 ` fweimer at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: drepper.fsp at gmail dot com @ 2011-01-10  3:18 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12373

Ulrich Drepper <drepper.fsp at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME

--- Comment #1 from Ulrich Drepper <drepper.fsp at gmail dot com> 2011-01-10 03:17:57 UTC ---
I cannot reproduce such a problem with gcc 4.5.1.  Perhaps a gcc problem.

I nevertheless changed the code since nowadays gcc generates better code with
the generic version of the macros than with the inline asms.

-- 
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] 3+ messages in thread

* [Bug libc/12373] FD_SET macro gives warning with -Wconversion (with solution)
  2011-01-07  9:11 [Bug libc/12373] New: FD_SET macro gives warning with -Wconversion (with solution) johan162 at gmail dot com
  2011-01-10  3:18 ` [Bug libc/12373] " drepper.fsp at gmail dot com
@ 2014-06-27 14:03 ` fweimer at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: fweimer at redhat dot com @ 2014-06-27 14:03 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=12373

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] 3+ messages in thread

end of thread, other threads:[~2014-06-27 14:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-07  9:11 [Bug libc/12373] New: FD_SET macro gives warning with -Wconversion (with solution) johan162 at gmail dot com
2011-01-10  3:18 ` [Bug libc/12373] " drepper.fsp at gmail dot com
2014-06-27 14:03 ` 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).