From nobody@FreeBSD.org  Thu Mar 10 09:28:03 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 873D5106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 10 Mar 2011 09:28:03 +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 762A68FC17
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 10 Mar 2011 09:28:03 +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 p2A9S3sT048203
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 10 Mar 2011 09:28:03 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p2A9S3o3048202;
	Thu, 10 Mar 2011 09:28:03 GMT
	(envelope-from nobody)
Message-Id: <201103100928.p2A9S3o3048202@red.freebsd.org>
Date: Thu, 10 Mar 2011 09:28:03 GMT
From: Steve Whiteley <stevew@srware.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Including malloc.h aborts compile.
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         155429
>Category:       kern
>Synopsis:       [headers] including malloc.h should not abort compile.
>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:   Thu Mar 10 09:30:11 UTC 2011
>Closed-Date:    
>Last-Modified:  Fri Mar 11 04:30:23 UTC 2011
>Originator:     Steve Whiteley
>Release:        7.3-release
>Organization:
Whiteley Research Inc.
>Environment:
FreeBSD kipling 7.3-RELEASE-p3 FreeBSD 7.3-RELEASE-p3 #3: Sun Oct  3 17:29:39 PDT 2010     stevew@kipling:/usr2/obj/usr2/src/sys/KIPLING  i386
>Description:
The is not really a bug, just (IMHO) a dumb decision that affects at
least up to 7.3.  Including <malloc.h> in a c++ source file aborts the
compile, with a message informing to include stdlib instead.  Well,
fine, but some source files written for other OSes may include malloc.h,
and are nonportable to FreeBSD simple because of this, i.e., if the
malloc.h include is commented out the file compiles fine.  The FreeBSD
malloc.h should be an empty stub, or at worst emit an info message that
malloc.h is not needed in FreeBSD.  But to abort the compile?

So I have the choice of hunting through a big source like OpenAccess
to fix all the malloc.h includes, or hacking the include file itself
(my approach, but it always reverts when I update).
>How-To-Repeat:
test.cc
---------
#include <malloc.h>
int main() { return 0; }
>Fix:
/* $FreeBSD: src/include/malloc.h,v 1.5.38.1 2010/02/10 00:26:20 kensmith Exp $
*/
#if __STDC__
/* XXX commented to avoid ridiculousness
#error "<malloc.h> has been replaced by <stdlib.h>"
*/
#else
#include <stdlib.h>
#endif


>Release-Note:
>Audit-Trail:
>Unformatted:
