From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31503 invoked by alias); 7 Jan 2011 09:11:33 -0000 Received: (qmail 31493 invoked by uid 22791); 7 Jan 2011 09:11:31 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO sourceware.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 07 Jan 2011 09:11:28 +0000 From: "johan162 at gmail dot com" To: glibc-bugs@sources.redhat.com Subject: [Bug libc/12373] New: FD_SET macro gives warning with -Wconversion (with solution) X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: johan162 at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: drepper.fsp at gmail dot com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Date: Fri, 07 Jan 2011 09:11:00 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2011-01/txt/msg00006.txt.bz2 http://sourceware.org/bugzilla/show_bug.cgi?id=3D12373 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 int main(void) { fd_set fds; int fd =3D 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 =E2=80=98main=E2=80=99: wtst.c:8: error: conversion to =E2=80=98unsigned int=E2=80=99 from =E2=80= =98int=E2=80=99 may change the sign of the result wtst.c:8: error: conversion to =E2=80=98unsigned int=E2=80=99 from =E2=80= =98int=E2=80=99 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 o= f 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" : "=3Dm" (((&fds)->__fds_bits)[((fd) /= (8 * sizeof (__fd_mask)))]) : "r" (((int) (fd)) % (8 * sizeof (__fd_mask))) : "cc","memory"); to __asm__ __volatile__ ("btsl %1,%0" : "=3Dm" (((&fds)->__fds_bits)[((unsigned)(fd) / (8 * sizeof (__fd_mask)))]) : "r" (((unsigned) (fd)) % (8 * sizeof (__fd_mask))) : "cc","memory"); --=20 Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=3Demail ------- You are receiving this mail because: ------- You are on the CC list for the bug.