This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/14210] New: warning when using FD_SET() with -Wsign-conversion and _FORTIFY_SOURCE
- From: "vapier at gentoo dot org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: Sat, 09 Jun 2012 03:46:02 +0000
- Subject: [Bug libc/14210] New: warning when using FD_SET() with -Wsign-conversion and _FORTIFY_SOURCE
- Auto-submitted: auto-generated
http://sourceware.org/bugzilla/show_bug.cgi?id=14210
Bug #: 14210
Summary: warning when using FD_SET() with -Wsign-conversion and
_FORTIFY_SOURCE
Product: glibc
Version: 2.15
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: unassigned@sourceware.org
ReportedBy: vapier@gentoo.org
CC: drepper.fsp@gmail.com
Classification: Unclassified
Target: x86_64-linux-gnu
starting with glibc-2.15, trying to use FD_SET according to the API results in
build time warnings when using -Wsign-conversion and fortification
$ cat test.c
#include <sys/select.h>
int main(int argc, char *argv[])
{
int fd = argc;
fd_set fds;
FD_ZERO(&fds);
FD_SET(fd, &fds);
return argv[0][fd];
}
$ gcc test.c -c -Wsign-conversion -O2 -Werror -D_FORTIFY_SOURCE=2
error: conversion to 'long unsigned int' from 'int' may change the sign of the
result [-Werror=sign-conversion]
this is because FD_SET assigns the int fd to an "unsigned int long" without a
cast, and that triggers signed warnings
--
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.