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

Reply via email to