Date: Mon, 29 Aug 2011 19:10:51 GMT From: Abe <abe_skolnik@yahoo.com> To: freebsd-gnats-submit@FreeBSD.org Subject: misc/160294: missing cast in "/usr/include/assert.h" v 1.4 2002/03/23 17:24:53 Message-ID: <201108291910.p7TJApQa036721@red.freebsd.org> Resent-Message-ID: <201108291920.p7TJKAJI044680@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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 <cassert>
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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201108291910.p7TJApQa036721>
