From mlelstv@dv2.dev.de.cw.net  Sat Jun 28 03:30:49 2003
Return-Path: <mlelstv@dv2.dev.de.cw.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id C72E837B401
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 28 Jun 2003 03:30:49 -0700 (PDT)
Received: from dv2.dev.de.cw.net (dv2.dev.de.cw.net [141.1.23.35])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 5A91543FBF
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 28 Jun 2003 03:30:48 -0700 (PDT)
	(envelope-from mlelstv@dv2.dev.de.cw.net)
Received: from dv2.dev.de.cw.net (localhost [127.0.0.1])
	by dv2.dev.de.cw.net (8.12.9/8.12.6) with ESMTP id h5SAU5C2035789
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 28 Jun 2003 12:30:46 +0200 (CEST)
	(envelope-from mlelstv@dv2.dev.de.cw.net)
Received: (from mlelstv@localhost)
	by dv2.dev.de.cw.net (8.12.9/8.12.9/Submit) id h5RARCOs099736;
	Fri, 27 Jun 2003 12:27:12 +0200 (CEST)
Message-Id: <200306271027.h5RARCOs099736@dv2.dev.de.cw.net>
Date: Fri, 27 Jun 2003 12:27:12 +0200 (CEST)
From: Michael van Elst <mlelstv@dev.de.cw.net>
Reply-To: Michael van Elst <mlelstv@dev.de.cw.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: C++ undeclares standard math functions like isinf()
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         53870
>Category:       bin
>Synopsis:       C++ undeclares standard math functions like isinf()
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    das
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jun 28 03:40:11 PDT 2003
>Closed-Date:    Wed Jan 03 05:30:01 GMT 2007
>Last-Modified:  Wed Jan 03 05:30:01 GMT 2007
>Originator:     Michael van Elst
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
dis-
>Environment:
System: FreeBSD dv2.dev.de.cw.net 5.1-CURRENT FreeBSD 5.1-CURRENT #0: Tue Jun 10 14:12:43 CEST 2003 root@dv2.dev.de.cw.net:/usr/src/sys/i386/compile/DV2 i386


	
>Description:
The following C++ program does not compile on FreeBSD5.*

#include <cmath>
void foo()
{
    double d;
    isinf(d);
}

The error message is:

c.cc: In function `void foo()':
c.cc:5: error: `isinf' undeclared (first use this function)
c.cc:5: error: (Each undeclared identifier is reported only once for each 
   function it appears in.)

This is caused by isinf() being a macro defined in math.h which is
then undef'd in the cmath header. The compiler _should_ then see the
underlying function implementation instead of the macro.

The same is true for some other functions declared in the near vicinity:

isinf()
isnan()
signbit()

and some others like fpclassify() and isfinite(). The latter however
do not exists as functions in libc.

The error appeared with the introduction of GCC3.3.

>How-To-Repeat:
See above
>Fix:

Add prototypes for isinf(), isnan(), signbit() functions to math.h.
Add function implementations for the other functions that are only
macros.

>Release-Note:
>Audit-Trail:

From: "Artem 'Zazoobr' Ignatjev" <timon@memphis.mephi.ru>
To: Michael van Elst <mlelstv@dev.de.cw.net>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/53870: C++ undeclares standard math functions like isinf()
Date: 28 Jun 2003 14:54:22 +0400

 Michael van Elst wrote:
 > >Description:
 > The following C++ program does not compile on FreeBSD5.*
 > 
 > #include <cmath>
 Add:
 using namespace std;
 > void foo()
 > {
 >     double d;
 >     isinf(d);
 > }
 > 
 
 

From: Michael van Elst <mlelstv@dev.de.cw.net>
To: Artem 'Zazoobr' Ignatjev <timon@memphis.mephi.ru>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/53870: C++ undeclares standard math functions like isinf()
Date: Sat, 28 Jun 2003 13:10:08 +0200

 On Sat, Jun 28, 2003, Artem 'Zazoobr' Ignatjev wrote:
 
 > > #include <cmath>
 > Add:
 > using namespace std;
 
 Thanks, this helps. Can you explain why this is necessary for isinf()
 but not for functions like sin() ?
 
 The only difference seems to be that isinf() happens to implemented as
 a macro (it used to be a function in FreeBSD4).
 
 Greetings,
 -- 
     ,eM""=.            a"-.                         Michael van Elst
    dWWMWM" -          :GM==;                        mlelstv@dev.de.cw.net
   :WWMWMw=--.          "W='  cable & wireless
    9WWMm==-.
     "-Wmw-"  CABLE & WIRELESS
State-Changed-From-To: open->analyzed 
State-Changed-By: bms 
State-Changed-When: Mon Jun 14 21:22:26 GMT 2004 
State-Changed-Why:  
Please see the following URL: 
http://gcc.gnu.org/ml/libstdc++/2003-04/msg00119.html 

As per above the following hack will work: 

#include <cmath> 
void foo() 
{ 
using namespace std; /* XXX */ 
double d; 
isinf(d); 
} 


Responsible-Changed-From-To: freebsd-bugs->kan 
Responsible-Changed-By: bms 
Responsible-Changed-When: Mon Jun 14 21:22:26 GMT 2004 
Responsible-Changed-Why:  
das@ has been handling some of this, so assign to him. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=53870 
Responsible-Changed-From-To: kan->das 
Responsible-Changed-By: bms 
Responsible-Changed-When: Tue Jun 15 22:33:25 GMT 2004 
Responsible-Changed-Why:  
Doh, my bad, meant das, not kan. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=53870 
State-Changed-From-To: analyzed->closed 
State-Changed-By: das 
State-Changed-When: Wed Jan 3 05:29:49 UTC 2007 
State-Changed-Why:  
First of all, if you include <cmath> (or any other new C++ header 
file) as opposed to <math.h>, the C++ standard says that all the 
declared symbols from the header file are placed in namespace std. 
The fact that your example program compiles on some systems without 
a `using namespace std;' line is a bug.  However, it seems that the 
version of gcc in FreeBSD 6.x re-introduces this bug for backwards 
compatiblity, so your program compiles once again. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=53870 
>Unformatted:
