https://bugzilla.novell.com/show_bug.cgi?id=651597 https://bugzilla.novell.com/show_bug.cgi?id=651597#c0 Summary: clib macro FD_SET gives warning with -Wconversion together with gcc (with solution) Classification: openSUSE Product: openSUSE 11.2 Version: Final Platform: x86 OS/Version: openSUSE 11.2 Status: NEW Severity: Normal Priority: P5 - None Component: Development AssignedTo: pth@novell.com ReportedBy: johanp@aditus.nu QAContact: qa@suse.de Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7 (I'm reporting it here rather than to gcc clib since this seem like a modification done by SuSE) It is not possible to compile the following code with gcc 4.4.1 and extra warnings enabled (in OpenSuSE 11.2) 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"); Reproducible: Always Steps to Reproduce: 1. Se example program in the details 2. 3. Actual Results: Compiler warning. It should be possible to build code even with -Wconversion enabled as warning Expected Results: Code compiles without warning The macro could as easily avoid the assembler inline expansion (which seems completely unnecessary to me) with a more standard macro expansion as (((&fds)->__fds_bits)[((fd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((fd) % (8 * (int) sizeof (__fd_mask))))); -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.