This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/12194] New: htons() gives warning if compiled with gcc -Wconversion
- From: "johan162 at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: Fri, 5 Nov 2010 07:03:39 +0000
- Subject: [Bug libc/12194] New: htons() gives warning if compiled with gcc -Wconversion
- Auto-submitted: auto-generated
http://sourceware.org/bugzilla/show_bug.cgi?id=12194
Summary: htons() gives warning if compiled with gcc
-Wconversion
Product: glibc
Version: 2.10
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper.fsp@gmail.com
ReportedBy: johan162@gmail.com
The following (legitimate) code will generate a warning when both -O2 and
-Wconversion is enabled but not when only -Wconversion is enabled.
Code:
#include <arpa/inet.h>
// Nonsense code to illustrate problem
int main(void) {
uint16_t portnbr=0;
uint16_t n_portnbr = htons(portnbr);
exit(0);
}
With optimization
$> gcc -std=gnu99 -Wconversion -Werror -O2 -c tsthtons.c
cc1: warnings being treated as errors
tsthtons.c: In function âmainâ:
tsthtons.c:6: error: conversion to âshort unsigned intâ from âintâ may alter
its value
and without
$>gcc -std=gnu99 -Wconversion -Werror -c tsthtons.c
$>
in both cases
gcc --version
gcc (SUSE Linux) 4.4.1 [gcc-4_4-branch revision 150839]
Copyright (C) 2009 Free Software Foundation, Inc.
and gnu clib v2.10.1
--
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.