public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/13924] New: #include<vector> imports partial definition of std::abs
@ 2004-01-29 20:43 reichelt at gcc dot gnu dot org
  2004-01-29 21:08 ` [Bug libstdc++/13924] " bangerth at dealii dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2004-01-29 20:43 UTC (permalink / raw)
  To: gcc-bugs

Compiling the following code snippet with gcc 3.4/mainline

======================================================
#include<vector>

double foo(double x)
{
    return std::abs(x);
}
======================================================

I get the following error message

xxx.cc: In function `double foo(double)':
xxx.cc:5: error: call of overloaded `abs(double&)' is ambiguous
<internal>:5: error: candidates are: int std::abs(int)
/home/Pakete/gcc/FARM/gcc-20031229/include/c++/3.3.3/cstdlib:119: error:        
            long int std::abs(long int)
/home/Pakete/gcc/FARM/gcc-20031229/include/c++/3.3.3/cstdlib:149: error:        
            long long int __gnu_cxx::abs(long long int)

Obviously <vector> only imports the integer version on std::abs.

(Previous versions compiled the code without error. I don't know whether
<vector> is allowed to include <cmath> as well, so I don't know whether
this behaviour is okay or not.)

Maybe this is actually an improvement towards a clean interface of
<vector>, but I still find it confusing that std::abs is imported
only partially.

-- 
           Summary: #include<vector> imports partial definition of std::abs
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: reichelt at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13924


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

* [Bug libstdc++/13924] #include<vector> imports partial definition of std::abs
  2004-01-29 20:43 [Bug libstdc++/13924] New: #include<vector> imports partial definition of std::abs reichelt at gcc dot gnu dot org
@ 2004-01-29 21:08 ` bangerth at dealii dot org
  2004-01-29 23:08 ` gdr at integrable-solutions dot net
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2004-01-29 21:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-01-29 21:08 -------
Confirmed. This is confusing. 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-01-29 21:08:26
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13924


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

* [Bug libstdc++/13924] #include<vector> imports partial definition of std::abs
  2004-01-29 20:43 [Bug libstdc++/13924] New: #include<vector> imports partial definition of std::abs reichelt at gcc dot gnu dot org
  2004-01-29 21:08 ` [Bug libstdc++/13924] " bangerth at dealii dot org
@ 2004-01-29 23:08 ` gdr at integrable-solutions dot net
  2004-01-29 23:28 ` bangerth at dealii dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-01-29 23:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2004-01-29 23:08 -------
Subject: Re:  New: #include<vector> imports partial definition of std::abs

"reichelt at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| (Previous versions compiled the code without error. I don't know whether
| <vector> is allowed to include <cmath> as well, so I don't know whether
| this behaviour is okay or not.)

The testcase is an invalid program, and a diagnostic is given.

The C++ standard explicilty allows (unlike the C standard) any
standard header to include any other standard headers.  So, this is
not a bug in V3.  

Furthermore, the overloads of std::abs are spread (by C++ standard
definition) over many headers. 

I suggest the PR be closed. 

-- Gaby


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13924


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

* [Bug libstdc++/13924] #include<vector> imports partial definition of std::abs
  2004-01-29 20:43 [Bug libstdc++/13924] New: #include<vector> imports partial definition of std::abs reichelt at gcc dot gnu dot org
  2004-01-29 21:08 ` [Bug libstdc++/13924] " bangerth at dealii dot org
  2004-01-29 23:08 ` gdr at integrable-solutions dot net
@ 2004-01-29 23:28 ` bangerth at dealii dot org
  2004-01-30  0:11 ` gdr at integrable-solutions dot net
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2004-01-29 23:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-01-29 23:28 -------
I'm not sure whether we should just close this PR. I mean, assume 
that by #including <vector> we had, for some reason, only got one 
std::abs function. Then the argument would have been converted 
and the program had compiled. While this is clearly the correct 
behavior of the compiler, it is a QoI issue whether we would want 
that or not. 
 
W. 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13924


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

* [Bug libstdc++/13924] #include<vector> imports partial definition of std::abs
  2004-01-29 20:43 [Bug libstdc++/13924] New: #include<vector> imports partial definition of std::abs reichelt at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2004-01-29 23:28 ` bangerth at dealii dot org
@ 2004-01-30  0:11 ` gdr at integrable-solutions dot net
  2004-01-30  0:24 ` pinskia at gcc dot gnu dot org
  2004-02-02 23:16 ` bangerth at dealii dot org
  5 siblings, 0 replies; 7+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-01-30  0:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2004-01-30 00:11 -------
Subject: Re:  #include<vector> imports partial definition of std::abs

"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| I'm not sure whether we should just close this PR.

We should :-)

| I mean, assume 
| that by #including <vector> we had, for some reason, only got one 
| std::abs function. Then the argument would have been converted 
| and the program had compiled. While this is clearly the correct 
| behavior of the compiler, it is a QoI issue whether we would want 
| that or not. 

But, if you want to use std::abs(), you're going to include the
appropriate header anyway.  I don't believe you can solve this kind of
problem in any satisfactory manner -- which is why there is that
explicit deviation from the C stanadard in the C++ standard.  Keeping
this PR open is pointless.  

See our set of slides on "What is the type of std::toupper?" at the
last ACCU03 conference for related issues.

-- Gaby


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13924


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

* [Bug libstdc++/13924] #include<vector> imports partial definition of std::abs
  2004-01-29 20:43 [Bug libstdc++/13924] New: #include<vector> imports partial definition of std::abs reichelt at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2004-01-30  0:11 ` gdr at integrable-solutions dot net
@ 2004-01-30  0:24 ` pinskia at gcc dot gnu dot org
  2004-02-02 23:16 ` bangerth at dealii dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-30  0:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-30 00:24 -------
I agree with Gaby here that the problem is that you are not including the right header file and this 
is never going to work the way you want it to work.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13924


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

* [Bug libstdc++/13924] #include<vector> imports partial definition of std::abs
  2004-01-29 20:43 [Bug libstdc++/13924] New: #include<vector> imports partial definition of std::abs reichelt at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2004-01-30  0:24 ` pinskia at gcc dot gnu dot org
@ 2004-02-02 23:16 ` bangerth at dealii dot org
  5 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2004-02-02 23:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-02-02 23:16 -------
*** Bug 13943 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |debian-gcc at lists dot
                   |                            |debian dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13924


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

end of thread, other threads:[~2004-02-02 23:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-29 20:43 [Bug libstdc++/13924] New: #include<vector> imports partial definition of std::abs reichelt at gcc dot gnu dot org
2004-01-29 21:08 ` [Bug libstdc++/13924] " bangerth at dealii dot org
2004-01-29 23:08 ` gdr at integrable-solutions dot net
2004-01-29 23:28 ` bangerth at dealii dot org
2004-01-30  0:11 ` gdr at integrable-solutions dot net
2004-01-30  0:24 ` pinskia at gcc dot gnu dot org
2004-02-02 23:16 ` bangerth at dealii dot org

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).