public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
@ 2003-05-11  9:16 gdr
  0 siblings, 0 replies; 14+ messages in thread
From: gdr @ 2003-05-11  9:16 UTC (permalink / raw)
  To: bkoz, gcc-bugs, gcc-prs, gdr, pete

Synopsis: Unable to use sqrt,cos,sin,... with int argument.

State-Changed-From-To: suspended->closed
State-Changed-By: gdr
State-Changed-When: Sun May 11 09:16:25 2003
State-Changed-Why:
    Fixed.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=3181


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
@ 2002-11-06 14:46 Phil Edwards
  0 siblings, 0 replies; 14+ messages in thread
From: Phil Edwards @ 2002-11-06 14:46 UTC (permalink / raw)
  To: gdr; +Cc: gcc-prs

The following reply was made to PR libstdc++/3181; it has been noted by GNATS.

From: Phil Edwards <phil@jaj.com>
To: bangerth@dealii.org, bkoz@gcc.gnu.org, gcc-bugs@gcc.gnu.org,
   gdr@gcc.gnu.org, pete@toyon.com, gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
Date: Wed, 6 Nov 2002 17:44:37 -0500

 On Wed, Nov 06, 2002 at 06:29:49PM -0000, bangerth@dealii.org wrote:
 >     
 >     (Why are the messages in the audit trail not in the right
 >     order, b.t.w.? My suspension message, refering to your
 >     request, comes _before_ the request...)
 
 Sometimes GNATS processes mail very quickly, and sometimes it takes half an
 hour or so.  Never in-between, just those two extremes.
 
 I won't accuse GNATS of actually being nondeterministic, but I have a theory
 that it depends on the phase of the moon.
 
 
 Phil
 
 -- 
 I would therefore like to posit that computing's central challenge, viz. "How
 not to make a mess of it," has /not/ been met.
                                                  - Edsger Dijkstra, 1930-2002


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
@ 2002-11-06 10:29 bangerth
  0 siblings, 0 replies; 14+ messages in thread
From: bangerth @ 2002-11-06 10:29 UTC (permalink / raw)
  To: bkoz, gcc-bugs, gcc-prs, gdr, pete

Synopsis: Unable to use sqrt,cos,sin,... with int argument.

Responsible-Changed-From-To: bkoz->gdr
Responsible-Changed-By: bangerth
Responsible-Changed-When: Wed Nov  6 10:29:46 2002
Responsible-Changed-Why:
    I got the wrong name hardwired when I read the first respons
    in the audit track, and never got I reset when Gaby replied
    to me. My bad.Sorry.
    
    (Why are the messages in the audit trail not in the right
    order, b.t.w.? My suspension message, refering to your
    request, comes _before_ the request...)

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=3181


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
@ 2002-11-06 10:16 Gabriel Dos Reis
  0 siblings, 0 replies; 14+ messages in thread
From: Gabriel Dos Reis @ 2002-11-06 10:16 UTC (permalink / raw)
  To: bkoz; +Cc: gcc-prs

The following reply was made to PR libstdc++/3181; it has been noted by GNATS.

From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: bangerth@dealii.org
Cc: bkoz@gcc.gnu.org, gcc-bugs@gcc.gnu.org, pete@toyon.com,
   gcc-gnats@gcc.gnu.org
Subject: Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
Date: 06 Nov 2002 19:15:30 +0100

 bangerth@dealii.org writes:
 
 | Synopsis: Unable to use sqrt,cos,sin,... with int argument.
 | 
 | Responsible-Changed-From-To: unassigned->bkoz
 | Responsible-Changed-By: bangerth
 | Responsible-Changed-When: Wed Nov  6 09:35:48 2002
 | Responsible-Changed-Why:
 |     You wanted it kept open :-)
 | State-Changed-From-To: analyzed->suspended
 | State-Changed-By: bangerth
 | State-Changed-When: Wed Nov  6 09:35:48 2002
 | State-Changed-Why:
 |     Given Benjamin's response, this is not a bug per se. He 
 |     wanted to keep it as a change-request, so I only suspend
 |     it.
 
 Err, I'm Gaby [ the person who replied to your query ] not Benjamin :-) :-)
 
 -- Gaby


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
@ 2002-11-06 10:06 Gabriel Dos Reis
  0 siblings, 0 replies; 14+ messages in thread
From: Gabriel Dos Reis @ 2002-11-06 10:06 UTC (permalink / raw)
  To: bkoz; +Cc: gcc-prs

The following reply was made to PR libstdc++/3181; it has been noted by GNATS.

From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
Cc: bkoz@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Subject: Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
Date: 06 Nov 2002 19:06:45 +0100

 Wolfgang Bangerth <bangerth@ticam.utexas.edu> writes:
 
 |  OK, will do that and also suspend it so that us bug crawlers don't trip 
 |  over it again and again.
 
 Excellent!
 
 -- Gaby


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
@ 2002-11-06  9:36 Wolfgang Bangerth
  0 siblings, 0 replies; 14+ messages in thread
From: Wolfgang Bangerth @ 2002-11-06  9:36 UTC (permalink / raw)
  To: bkoz; +Cc: gcc-prs

The following reply was made to PR libstdc++/3181; it has been noted by GNATS.

From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: Gabriel Dos Reis <gdr@integrable-solutions.net>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
Date: Wed, 6 Nov 2002 11:33:58 -0600 (CST)

 > |  However, are the overloads for int mandated?
 > 
 > No, there are not.  In fact adding such overloads would tehcnically
 > mean non-conformance (even though we all agree that C++ broke things
 > here).
 
 Right.
 
 > | I think not (only floating 
 > |  point types), and then the bug is not a bug and should be closed, right?
 > 
 > Well, mark it as a request-feature (I want to have it somehow "active"
 > but in the passive sense :-)
 
 OK, will do that and also suspend it so that us bug crawlers don't trip 
 over it again and again.
 
 Thanks
   W.
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
                                www: http://www.ticam.utexas.edu/~bangerth
 
 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
@ 2002-11-06  9:36 Gabriel Dos Reis
  0 siblings, 0 replies; 14+ messages in thread
From: Gabriel Dos Reis @ 2002-11-06  9:36 UTC (permalink / raw)
  To: bkoz; +Cc: gcc-prs

The following reply was made to PR libstdc++/3181; it has been noted by GNATS.

From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
Date: 06 Nov 2002 18:29:24 +0100

 Wolfgang Bangerth <bangerth@ticam.utexas.edu> writes:
 
 | The following reply was made to PR libstdc++/3181; it has been noted by GNATS.
 | 
 | From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
 | To: gcc-gnats@gcc.gnu.org
 | Cc:  
 | Subject: Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
 | Date: Wed, 6 Nov 2002 11:18:58 -0600 (CST)
 | 
 |  ...and still with 3.3 CVS from 20021103.
 |  
 |  However, are the overloads for int mandated?
 
 No, there are not.  In fact adding such overloads would tehcnically
 mean non-conformance (even though we all agree that C++ broke things
 here).
 
 | I think not (only floating 
 |  point types), and then the bug is not a bug and should be closed, right?
 
 Well, mark it as a request-feature (I want to have it somehow "active"
 but in the passive sense :-)
 
 -- Gaby


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
@ 2002-11-06  9:35 bangerth
  0 siblings, 0 replies; 14+ messages in thread
From: bangerth @ 2002-11-06  9:35 UTC (permalink / raw)
  To: bkoz, gcc-bugs, gcc-prs, nobody, pete

Synopsis: Unable to use sqrt,cos,sin,... with int argument.

Responsible-Changed-From-To: unassigned->bkoz
Responsible-Changed-By: bangerth
Responsible-Changed-When: Wed Nov  6 09:35:48 2002
Responsible-Changed-Why:
    You wanted it kept open :-)
State-Changed-From-To: analyzed->suspended
State-Changed-By: bangerth
State-Changed-When: Wed Nov  6 09:35:48 2002
State-Changed-Why:
    Given Benjamin's response, this is not a bug per se. He 
    wanted to keep it as a change-request, so I only suspend
    it.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=3181


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
@ 2002-11-06  9:26 Wolfgang Bangerth
  0 siblings, 0 replies; 14+ messages in thread
From: Wolfgang Bangerth @ 2002-11-06  9:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR libstdc++/3181; it has been noted by GNATS.

From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: gcc-bugs@gcc.gnu.org, <bkoz@gcc.gnu.org>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
Date: Wed, 6 Nov 2002 11:21:31 -0600 (CST)

 Benjamin,
 3181 is about the following:
   std::sqrt(1)
 and 
   int i; std::sqrt(i)
 giving overload resolution ambiguities. Since the overloads are only 
 provided for floating point types, this is not surprising, so I would say 
 that this is actually standards conforming behavior, right? In this case, 
 we should close this report.
 
 Regards
   Wolfgang
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
                                www: http://www.ticam.utexas.edu/~bangerth
 
 
 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
@ 2002-11-06  9:16 Wolfgang Bangerth
  0 siblings, 0 replies; 14+ messages in thread
From: Wolfgang Bangerth @ 2002-11-06  9:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR libstdc++/3181; it has been noted by GNATS.

From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
Date: Wed, 6 Nov 2002 11:18:58 -0600 (CST)

 ...and still with 3.3 CVS from 20021103.
 
 However, are the overloads for int mandated? I think not (only floating 
 point types), and then the bug is not a bug and should be closed, right?
 
 W.
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
                                www: http://www.ticam.utexas.edu/~bangerth
 
 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
@ 2002-04-19 12:46 Phil Edwards
  0 siblings, 0 replies; 14+ messages in thread
From: Phil Edwards @ 2002-04-19 12:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR libstdc++/3181; it has been noted by GNATS.

From: Phil Edwards <phil@jaj.com>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
Date: Fri, 19 Apr 2002 15:40:54 -0400

 Just to keep the audit trail alive:  still happens on i686-linux using
 3.1 20020418 (prerelease).
 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
@ 2001-06-20  9:26 Peter J. Stieber
  0 siblings, 0 replies; 14+ messages in thread
From: Peter J. Stieber @ 2001-06-20  9:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR libstdc++/3181; it has been noted by GNATS.

From: "Peter J. Stieber" <pete@toyon.com>
To: <bkoz@gcc.gnu.org>, <nobody@gcc.gnu.org>, <gcc-prs@gcc.gnu.org>,
        <gcc-bugs@gcc.gnu.org>
Cc: <gcc-gnats@gcc.gnu.org>
Subject: Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
Date: Wed, 20 Jun 2001 09:16:12 -0700

 The book by Nicolai Josuttis "The C++ Standard Library - A Tutorial and
 Reference" has a good discussion of this topic (pp.581-582 in my copy). The
 fact that standard conforming behavior is defined as overloading the
 functions for all floating-point types (float, double and long double) leads
 to this problem. In the old days, non-standard function names were used
 (sqrtf, sqrtl, cosf, cosl,...) for the other floating point types, so
 implicit conversion would work. It is common in numeric programming
 (although not good practice) to see code like:
 
 double Pi = acos(-1);
 
 This will now cause problems, but it's always nice to work with legacy code.
 Since the old standard function names were defined for double
 FunctionName(double), you could overload for all numeric types and cast:
 
 namespace std
 {
   double sqrt(int a)
   {
     return sqrt(static_cast<double>(a));
   }
   double sqrt(long a)
   {
     return sqrt(static_cast<double>(a));
   }
 .
 .
 .
 };
 
 This behavior could be controlled by compiler switches or using the
 preprocessor.
 
 The work-around I use in my code is to make the following changes
 
 acos(-1)  change to acos(-1.0)
 
 or
 
 int i;
 acos(i) changes to acos(static_cast<double>(i))
 
 but for large projects, this would be a pain.
 
 
 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
@ 2001-06-13 19:43 bkoz
  0 siblings, 0 replies; 14+ messages in thread
From: bkoz @ 2001-06-13 19:43 UTC (permalink / raw)
  To: bkoz, gcc-bugs, gcc-prs, nobody, pete

Synopsis: Unable to use sqrt,cos,sin,... with int argument.

State-Changed-From-To: open->analyzed
State-Changed-By: bkoz
State-Changed-When: Wed Jun 13 19:43:00 2001
State-Changed-Why:
    Can you show me an example of the casts that work?
    

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3181&database=gcc


^ permalink raw reply	[flat|nested] 14+ messages in thread

* libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument.
@ 2001-06-13 16:46 pete
  0 siblings, 0 replies; 14+ messages in thread
From: pete @ 2001-06-13 16:46 UTC (permalink / raw)
  To: gcc-gnats; +Cc: bkoz

>Number:         3181
>Category:       libstdc++
>Synopsis:       Unable to use sqrt,cos,sin,... with int argument.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 13 16:46:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Pete Stieber
>Release:        gcc version 3.1 20010611 (experimental)
>Organization:
>Environment:
i686-pc-linux-gnu
Red Hat 7.1
>Description:
Error compiling std library math functions with in arguments. Automatic type conversion not working:

test.cpp: In function `int main()':
test.cpp:11: call of overloaded `sqrt(int&)' is ambiguous
/usr/include/bits/mathcalls.h:146: candidates are: double sqrt(double)
/usr/local/include/g++-v3/bits/std_cmath.h:461:                 long double    std::sqrt(long double)
/usr/local/include/g++-v3/bits/std_cmath.h:455:                 float    std::sqrt(float)
>How-To-Repeat:
gcc test.cpp
>Fix:
I have to cast int/long/... instead of automatic conversion.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="test.cpp"
Content-Disposition: inline; filename="test.cpp"

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
  int i = -1;
  double Ans;
  // All of the functions have the problem, but we will use sqrt to illustrate.
  Ans = sqrt(i);
  cout << Ans << endl;
//  Ans = cos(i);
//  cout << Ans << endl;
//  Ans = sin(i);
//  cout << Ans << endl;
//  Ans = tan(i);
//  cout << Ans << endl;
//  Ans = acos(i);
//  cout << Ans << endl;
//  Ans = asin(i);
//  cout << Ans << endl;
//  Ans = atan(i);
//  cout << Ans << endl;

  return 1;
}


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2003-05-11  9:16 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-11  9:16 libstdc++/3181: Unable to use sqrt,cos,sin,... with int argument gdr
  -- strict thread matches above, loose matches on Subject: below --
2002-11-06 14:46 Phil Edwards
2002-11-06 10:29 bangerth
2002-11-06 10:16 Gabriel Dos Reis
2002-11-06 10:06 Gabriel Dos Reis
2002-11-06  9:36 Wolfgang Bangerth
2002-11-06  9:36 Gabriel Dos Reis
2002-11-06  9:35 bangerth
2002-11-06  9:26 Wolfgang Bangerth
2002-11-06  9:16 Wolfgang Bangerth
2002-04-19 12:46 Phil Edwards
2001-06-20  9:26 Peter J. Stieber
2001-06-13 19:43 bkoz
2001-06-13 16:46 pete

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).