From owner-freebsd-bugs@FreeBSD.ORG Mon Aug 29 19:20:10 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4C07F106566B for ; Mon, 29 Aug 2011 19:20:10 +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 29CC28FC17 for ; Mon, 29 Aug 2011 19:20:10 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p7TJKAl1044681 for ; Mon, 29 Aug 2011 19:20:10 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p7TJKAJI044680; Mon, 29 Aug 2011 19:20:10 GMT (envelope-from gnats) Resent-Date: Mon, 29 Aug 2011 19:20:10 GMT Resent-Message-Id: <201108291920.p7TJKAJI044680@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Abe Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 259361065670 for ; Mon, 29 Aug 2011 19:10:52 +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 F02598FC1B for ; Mon, 29 Aug 2011 19:10:51 +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 p7TJApdl036722 for ; Mon, 29 Aug 2011 19:10:51 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id p7TJApQa036721; Mon, 29 Aug 2011 19:10:51 GMT (envelope-from nobody) Message-Id: <201108291910.p7TJApQa036721@red.freebsd.org> Date: Mon, 29 Aug 2011 19:10:51 GMT From: Abe To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/160294: missing cast in "/usr/include/assert.h" v 1.4 2002/03/23 17:24:53 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: Mon, 29 Aug 2011 19:20:10 -0000 >Number: 160294 >Category: misc >Synopsis: missing cast in "/usr/include/assert.h" v 1.4 2002/03/23 17:24:53 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Aug 29 19:20:09 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Abe >Release: Mac OS X Server 10.6.5 ;-) >Organization: TAMU >Environment: Darwin [hostname] 10.5.0 Darwin Kernel Version 10.5.0: Fri Nov 5 23:20:39 PDT 2010; root:xnu-1504.9.17~1/RELEASE_I386 i386 i386 >Description: The "/usr/include/assert.h" from FreeBSD causes C++ compilation to fail when an assertion is done and the compiler is non-GCC _and_ does not define "__GNUC__" _and_ "NDEBUG" is not defined. It`s a simple and quick fix. >How-To-Repeat: compile this: ––––––––––––– #include int main() { assert(1); } ––––––––––––– like this [assuming Clang is installed and is on the PATH]: ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– clang++ -U__GNUC__ test.cpp ––––––––––––––––––––––––––– … and one of the errors you get is this: –––––––––––––––––––––––––––––––––––––––– test.cpp:3:3: error: right operand to ? is void, but left operand is of type 'int' assert(1); ^~~~~~~~~ In file included from test.cpp:1: In file included from /usr/include/c++/4.2.1/cassert:48: /usr/include/assert.h:69:18: note: instantiated from: ((void) ((e) ? 0 : __assert (#e, __FILE__, __LINE__))) ^ ~ >Fix: *** /usr/include/assert.h 2009-10-02 01:24:01.000000000 -0500 --- /tmp/assert.h___new 2011-08-28 21:39:12.000000000 -0500 *************** *** 66,72 **** __END_DECLS #define assert(e) \ ! ((void) ((e) ? 0 : __assert (#e, __FILE__, __LINE__))) #define __assert(e, file, line) \ ((void)printf ("%s:%u: failed assertion `%s'\n", file, line, e), abort()) --- 66,72 ---- __END_DECLS #define assert(e) \ ! ((void) ((e) ? ((void)0) : __assert (#e, __FILE__, __LINE__))) #define __assert(e, file, line) \ ((void)printf ("%s:%u: failed assertion `%s'\n", file, line, e), abort()) q Patch attached with submission follows: *** /usr/include/assert.h 2009-10-02 01:24:01.000000000 -0500 --- /tmp/assert.h___new 2011-08-28 21:39:12.000000000 -0500 *************** *** 66,72 **** __END_DECLS #define assert(e) \ ! ((void) ((e) ? 0 : __assert (#e, __FILE__, __LINE__))) #define __assert(e, file, line) \ ((void)printf ("%s:%u: failed assertion `%s'\n", file, line, e), abort()) --- 66,72 ---- __END_DECLS #define assert(e) \ ! ((void) ((e) ? ((void)0) : __assert (#e, __FILE__, __LINE__))) #define __assert(e, file, line) \ ((void)printf ("%s:%u: failed assertion `%s'\n", file, line, e), abort()) >Release-Note: >Audit-Trail: >Unformatted: