From owner-freebsd-i386@FreeBSD.ORG Mon Jun 18 00:40:11 2012 Return-Path: Delivered-To: freebsd-i386@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BB09B106566B for ; Mon, 18 Jun 2012 00:40:11 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 7A96A8FC0C for ; Mon, 18 Jun 2012 00:40:11 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q5I0eB1c088321 for ; Mon, 18 Jun 2012 00:40:11 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q5I0eBVv088320; Mon, 18 Jun 2012 00:40:11 GMT (envelope-from gnats) Resent-Date: Mon, 18 Jun 2012 00:40:11 GMT Resent-Message-Id: <201206180040.q5I0eBVv088320@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-i386@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Eric McCorkle Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 47B5F1065670 for ; Mon, 18 Jun 2012 00:39:31 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 336F68FC0A for ; Mon, 18 Jun 2012 00:39:31 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q5I0dU29022003 for ; Mon, 18 Jun 2012 00:39:30 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id q5I0dUY7022002; Mon, 18 Jun 2012 00:39:30 GMT (envelope-from nobody) Message-Id: <201206180039.q5I0dUY7022002@red.freebsd.org> Date: Mon, 18 Jun 2012 00:39:30 GMT From: Eric McCorkle To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: i386/169187: Bad sizeof(uint64_t) with -m32 compiler flag X-BeenThere: freebsd-i386@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: I386-specific issues for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2012 00:40:11 -0000 >Number: 169187 >Category: i386 >Synopsis: Bad sizeof(uint64_t) with -m32 compiler flag >Confidential: no >Severity: serious >Priority: high >Responsible: freebsd-i386 >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Jun 18 00:40:11 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Eric McCorkle >Release: 9.0, also appears on 10.0 >Organization: >Environment: FreeBSD atom-edge 9.0-STABLE FreeBSD 9.0-STABLE #118 r236960M: Wed Jun 13 08:44:31 EDT 2012 root@atom-edge:/usr/obj/usr/src/sys/CUSTOM amd64 >Description: When compiling programs on an amd64 machine with the -m32 compiler flag, uint64_t variables are incorrectly sized, resulting in sizeof(uint64_t) == 4. Presumably this affects int64_t as well, and any types that are typedef'ed to one of these. >How-To-Repeat: Compile the following program: #include #include int main() { printf("%d\n", sizeof(uint64_t)); return 0; } with the following command: gcc -m32 -o test test.c The output will be "4" as opposed to "8" like it should be. >Fix: The file defines __uint64_t as unsigned long on amd64 platforms. When compiling with -m32, however, the compiler makes unsigned long a 32-bit integer, which seems to be the root of the problem. A simple fix is to detect when sizeof(unsigned long) == 4, and define __uint64_t as unsigned long long instead. >Release-Note: >Audit-Trail: >Unformatted: