[Bug 1016349] Re: htons() returns wrong type on non-{i386, amd64} platforms

Bug Watch Updater 1016349 at bugs.launchpad.net
Fri Jun 22 03:57:18 UTC 2012


Launchpad has imported 5 comments from the remote bug at
http://sourceware.org/bugzilla/show_bug.cgi?id=12194.

If you reply to an imported comment from within Launchpad, your comment
will be sent to the remote bug automatically. Read more about
Launchpad's inter-bugtracker facilities at
https://help.launchpad.net/InterBugTracking.

------------------------------------------------------------------------
On 2010-11-05T07:03:34+00:00 Johan Persson wrote:

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

Reply at: https://bugs.launchpad.net/eglibc/+bug/1016349/comments/0

------------------------------------------------------------------------
On 2010-11-10T07:54:40+00:00 Drepper-fsp wrote:

Changed in git.

Reply at: https://bugs.launchpad.net/eglibc/+bug/1016349/comments/1

------------------------------------------------------------------------
On 2012-06-20T05:56:27+00:00 Anders Kaseorg wrote:

Shouldn’t the same change
(http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=69da074d7adfab7b57004a0dea9403a928e310a5)
be applied to sysdeps/s390/bits/byteswap.h and the generic
bits/byteswap.h?

Reply at: https://bugs.launchpad.net/eglibc/+bug/1016349/comments/2

------------------------------------------------------------------------
On 2012-06-20T07:19:45+00:00 Aj-suse wrote:

thanks, patch send: http://sourceware.org/ml/libc-
alpha/2012-06/msg00550.html

Reply at: https://bugs.launchpad.net/eglibc/+bug/1016349/comments/3

------------------------------------------------------------------------
On 2012-06-21T13:52:12+00:00 Aj-suse wrote:

Fixed for glibc 2.16 now with:

commit 2174c6dd8555f654c30df2f8f3321b69e0f736f8
Author: Andreas Jaeger <aj at suse.de>
Date:   Thu Jun 21 15:49:33 2012 +0200

    Avoid -Wconversion warning for htons

Reply at: https://bugs.launchpad.net/eglibc/+bug/1016349/comments/4


** Changed in: eglibc
       Status: Unknown => Fix Released

** Changed in: eglibc
   Importance: Unknown => Medium

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to eglibc in Ubuntu.
https://bugs.launchpad.net/bugs/1016349

Title:
  htons() returns wrong type on non-{i386,amd64} platforms

Status in Embedded GLIBC:
  Fix Released
Status in “eglibc” package in Ubuntu:
  Confirmed
Status in “glibc” package in Fedora:
  Unknown

Bug description:
  The definition of htons() on platforms other than i386 and amd64 is
  missing a cast to uint16_t, which caused this FTBFS of mosh on armel
  and armhf:

  https://launchpad.net/ubuntu/+source/mosh/1.2.1-1ubuntu1/+build/3582950
  network.cc:76:28: error: narrowing conversion of '({...})' from 'unsigned int' to 'uint16_t {aka short unsigned int}' inside { } is ill-formed in C++11 [-Werror=narrowing]
  network.cc:76:50: error: narrowing conversion of '({...})' from 'unsigned int' to 'uint16_t {aka short unsigned int}' inside { } is ill-formed in C++11 [-Werror=narrowing]

  (We didn’t see this before because this warning is new in GCC 4.7.)

  This was fixed for glibc 2.16 in
  http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=2174c6dd8555f654c30df2f8f3321b69e0f736f8

To manage notifications about this bug go to:
https://bugs.launchpad.net/eglibc/+bug/1016349/+subscriptions




More information about the foundations-bugs mailing list