This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/12194] New: htons() gives warning if compiled with gcc -Wconversion

           Summary: htons() gives warning if compiled with gcc
           Product: glibc
           Version: 2.10
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc

The following (legitimate) code will generate a warning when both -O2 and 
-Wconversion is enabled but not when only -Wconversion is enabled. 

#include <arpa/inet.h>
// Nonsense code to illustrate problem
int main(void) {
    uint16_t portnbr=0;
    uint16_t n_portnbr = htons(portnbr);

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:
------- You are receiving this mail because: -------
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]