[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#350793: marked as done (htons() has wrong type at -O)



Your message dated Mon, 14 Mar 2016 01:17:21 +0100
with message-id <20160314001721.GA29760@aurel32.net>
and subject line Bug#350793: htons() has wrong type at -O
has caused the Debian Bug report #350793,
regarding htons() has wrong type at -O
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
350793: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=350793
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: libc6.1-dev
Version: 2.3.5-12
Severity: normal
File: /usr/include/arpa/inet.h

falk@juist:/tmp% cat test.c      
#include <arpa/inet.h>
int f() { return ntohs(1) > 1u; }
falk@juist:/tmp% gcc -c -W test.c
falk@juist:/tmp% gcc -c -W -O test.c
test.c: In function 'f':
test.c:2: warning: comparison between signed and unsigned

This is because htons is inlined to:

int f() { return (__extension__ ({ unsigned short int __bsx = (1); ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8)); })) > 1u; }

and because of C's promotion rules, the ({}) expression has type
signed int. However, htons is supposed to return uint16_t.

This makes nepenthes FTBFS (it has -Werror). I tried to imagine a
situation where it might lead to wrong code, but couldn't think of
one, short of taking sizeof htons().

	Falk



-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: alpha
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.13.2
Locale: LANG=C, LC_CTYPE=de_DE@euro (charmap=ISO-8859-15)

Versions of packages libc6.1-dev depends on:
ii  libc6.1                    2.3.5-12      GNU C Library: Shared libraries an
ii  linux-kernel-headers       2.6.13+0rc3-2 Linux Kernel Headers for developme

Versions of packages libc6.1-dev recommends:
ii  gcc [c-compiler]              4:4.0.2-2  The GNU C compiler
ii  gcc-3.3 [c-compiler]          1:3.3.6-12 The GNU C compiler
ii  gcc-4.0 [c-compiler]          4.0.2-8    The GNU C compiler

-- no debconf information


--- End Message ---
--- Begin Message ---
Version: 2.17-1

On 2006-01-31 21:52, Falk Hueffner wrote:
> Package: libc6.1-dev
> Version: 2.3.5-12
> Severity: normal
> File: /usr/include/arpa/inet.h
> 
> falk@juist:/tmp% cat test.c      
> #include <arpa/inet.h>
> int f() { return ntohs(1) > 1u; }
> falk@juist:/tmp% gcc -c -W test.c
> falk@juist:/tmp% gcc -c -W -O test.c
> test.c: In function 'f':
> test.c:2: warning: comparison between signed and unsigned
> 
> This is because htons is inlined to:
> 
> int f() { return (__extension__ ({ unsigned short int __bsx = (1); ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8)); })) > 1u; }
> 
> and because of C's promotion rules, the ({}) expression has type
> signed int. However, htons is supposed to return uint16_t.
> 
> This makes nepenthes FTBFS (it has -Werror). I tried to imagine a
> situation where it might lead to wrong code, but couldn't think of
> one, short of taking sizeof htons().

This bugs has been fixed in the following upstream commit:

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

      Avoid -Wconversion warning for htons

It went into glibc 2.16, so for debian it has been fixed in 2.17-1. I
am therefore closing the bug.

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                 http://www.aurel32.net

--- End Message ---

Reply to: