public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/19279] New: wrong code due to name import from the implementation of the standard library
@ 2005-01-05 20:17 o dot kullmann at swansea dot ac dot uk
  2005-01-05 20:25 ` [Bug c++/19279] " pinskia at gcc dot gnu dot org
  2005-01-05 21:17 ` gdr at integrable-solutions dot net
  0 siblings, 2 replies; 3+ messages in thread
From: o dot kullmann at swansea dot ac dot uk @ 2005-01-05 20:17 UTC (permalink / raw)
  To: gcc-bugs

For example with 
 
#include <vector> 
#include <cassert> 
double close(double) { return 1239; } 
int main() { 
  assert(close(10) == 1239); 
} 
 
which should run without asserting, actually the assert fails. 
 
The reason is that <vector> includes 
/usr/include/unistd.h 
which defines 
int close(int) 
and which is preferred over the above version of close. 
 
The above code is just a trivial example for wrong code produced 
by g++; in my code is was much harder to find the problem, and 
actually anything can happen with "close" and likely many other 
names included by the implementation of the standard library. 
 
I consider this bug as very serious (it can ruin any perfectly valid 
program). Of course, once you know the problem for this name, you 
can work around it, but then g++ is not a C++ compiler anymore, and how 
to know the critical names??? 
 
In the list of known bugs I couldn't find anything mentioned in the above 
direction, but it seems to me, that serious warnings must be posted.

-- 
           Summary: wrong code due to name import from the implementation of
                    the standard library
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: o dot kullmann at swansea dot ac dot uk
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/19279] wrong code due to name import from the implementation of the standard library
  2005-01-05 20:17 [Bug c++/19279] New: wrong code due to name import from the implementation of the standard library o dot kullmann at swansea dot ac dot uk
@ 2005-01-05 20:25 ` pinskia at gcc dot gnu dot org
  2005-01-05 21:17 ` gdr at integrable-solutions dot net
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-05 20:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-05 20:24 -------
This is a dup of bug 6257.  Yes this is a known problem, basically read about the c* files and how 
namespaces are done.  But another thing is close is not part of the C or C++ standard IIRC but part of 
the POSIX standard so this gets confusing.

*** This bug has been marked as a duplicate of 6257 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


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

* [Bug c++/19279] wrong code due to name import from the implementation of the standard library
  2005-01-05 20:17 [Bug c++/19279] New: wrong code due to name import from the implementation of the standard library o dot kullmann at swansea dot ac dot uk
  2005-01-05 20:25 ` [Bug c++/19279] " pinskia at gcc dot gnu dot org
@ 2005-01-05 21:17 ` gdr at integrable-solutions dot net
  1 sibling, 0 replies; 3+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-01-05 21:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2005-01-05 21:17 -------
Subject: Re:  wrong code due to name import from the implementation of the standard library

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

| This is a dup of bug 6257.  Yes this is a known problem, basically
| read about the c* files and how namespaces are done.  But another
| thing is close is not part of the C or C++ standard IIRC but part of  
| the POSIX standard so this gets confusing.

For the latter reason, this bug is not in the realm of GCC, and much
less of g++ or libstdc++.  This issue has to be taken up to system
packagers and POSIX people as they have managed to produce conflicting
requirements leading to fear, uncertainty and doubts about well
thought systems and programs.

And that is a pain in the ass.

I can understand the submitter's frustration.
Personaly, yesterday I wasted time looking for causes of build failure
in the Axiom computer algebra system

     http://www.nongnu.org/axiom/

only to figure out that some glibc-based systems have taken the right
to hijack names in user name space (in my case, some macros "likely"
and "unlikely" were defined!)

 http://lists.nongnu.org/archive/html/axiom-developer/2005-01/msg00040.html

-- Gaby


-- 


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


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

end of thread, other threads:[~2005-01-05 21:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-05 20:17 [Bug c++/19279] New: wrong code due to name import from the implementation of the standard library o dot kullmann at swansea dot ac dot uk
2005-01-05 20:25 ` [Bug c++/19279] " pinskia at gcc dot gnu dot org
2005-01-05 21:17 ` gdr at integrable-solutions dot net

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