From owner-freebsd-bugs@FreeBSD.ORG Wed May 19 15:22:31 2010 Return-Path: Delivered-To: freebsd-bugs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 155D8106564A for ; Wed, 19 May 2010 15:22:30 +0000 (UTC) (envelope-from christian.siebert@informatik.tu-chemnitz.de) Received: from jessica.hrz.tu-chemnitz.de (jessica.hrz.tu-chemnitz.de [134.109.132.47]) by mx1.freebsd.org (Postfix) with ESMTP id B7EA08FC0A for ; Wed, 19 May 2010 15:22:29 +0000 (UTC) Received: from galba.hrz.tu-chemnitz.de ([134.109.133.156] helo=mailbox.hrz.tu-chemnitz.de) by jessica.hrz.tu-chemnitz.de with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1OEkdR-00014S-GM; Wed, 19 May 2010 16:52:37 +0200 Received: from aiken.hrz.tu-chemnitz.de ([134.109.133.143] helo=localhost) by mailbox.hrz.tu-chemnitz.de with esmtp (Exim 4.69) (envelope-from ) id 1OEkdR-0006lB-Dg; Wed, 19 May 2010 16:52:37 +0200 Received: from grs-134-130-54-123.nn.RWTH-Aachen.DE (grs-134-130-54-123.nn.RWTH-Aachen.DE [134.130.54.123]) by mail.tu-chemnitz.de (Horde Framework) with HTTP; Wed, 19 May 2010 16:52:37 +0200 Message-ID: <20100519165237.80222q5mxazqxtth@mail.tu-chemnitz.de> Date: Wed, 19 May 2010 16:52:37 +0200 From: Christian Siebert To: freebsd-bugs@FreeBSD.org, bugs@openbsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; DelSp="Yes"; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: 7bit User-Agent: Internet Messaging Program (IMP) H3 (4.3.6) X-Originating-IP: 134.130.54.123 X-Scan-Signature: 489ffd0e04f7de08dacf4c0626a7b16e Cc: Subject: wrong datatype in stdlib/merge.c X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2010 15:22:31 -0000 Hi all, this file hasn't been touch for quite a while, so I'm wondering why nobody discovered this bug before. Location: in src/lib/libc/stdlib/merge.c in function setup() What is wrong: variable 'tmp' is an 'int' type Correction: this variable 'tmp' should be an 'u_char' type While this variable 'tmp' is used correctly in the other function insertionsort(), it is here (in setup) used incorrectly. At best, the compiler detects this problem (icc for example issues a remark) and corrects it automatically. More likely (gcc?) it just turns into unnecessary type conversions, leading to some performance loss. In the worst case (I think/hope not), this might even be problematic, because the result is written back to memory within the macros swap() and reverse(). Since the bug should be easy to fix, I'm looking forward to the appropriate commit. Best regards, Christian PS: I don't know who is responsible for this function, but it seems to be no standard ANSI/ISO C, but rather a BSD extension (according to the man pages at least). So I just checked the OpenBSD and FreeBSD web cvs and both showed this bug.