public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* Compilation of <vector> and self-defined 'distance(a,b)' fails
@ 2004-05-26  6:59 Benjamin King
  2004-06-01  1:29 ` Jim Wilson
  0 siblings, 1 reply; 2+ messages in thread
From: Benjamin King @ 2004-05-26  6:59 UTC (permalink / raw)
  To: gcc-bugs

[-- Attachment #1: Type: text/plain, Size: 2226 bytes --]

Hi GCC team,

I think my gcc has a bug. It fails to compile the following program. Renaming 'distance' to anything else solves this, so I guess that the 'distance' function from <iterator> somehow escaped the std::-namespace.
I couldn't find any description about this with google or in the gcc bug database.

cheers,
   Benjamin


My code (see attachment for .ii):
---
#include <vector>

double distance(const std::vector<double> & v1, const std::vector<double> & v2) {
   return 0;
}

int main(int argc, char* argv[])
{
   std::vector<double> v;
   double d;
   d = distance(v, v);
   return 0;
}
---


gcc -v:
---
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/specs
Configured with: /var/tmp/portage/gcc-3.3.2-r5/work/gcc-3.3.2/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3 --includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/info --enable-shared --host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --with-system-zlib --enable-languages=c,c++,f77,objc,java --enable-threads=posix --enable-long-long --disable-checking --enable-cstdio=stdio --enable-clocale=generic --enable-__cxa_atexit --enable-version-specific-runtime-libs --with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/include/g++-v3 --with-local-prefix=/usr/local --enable-shared --enable-nls --without-included-gettext --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --enable-interpreter --enable-java-awt=xlib --with-x --disable-multilib
Thread model: posix
gcc version 3.3.2 20031218 (Gentoo Linux 3.3.2-r5, propolice-3.3-7)
---


Command line:
---
gcc -pedantic -Wall minifail.cpp
---


Compiler output:
---
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/include/g++-v3/bits/stl_iterator_base_types.h: In instantiation of `std::iterator_traits<std::vector<double, std::allocator<double> > >':
minifail.cpp:11:   instantiated from here
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/include/g++-v3/bits/stl_iterator_base_types.h:126: error: no
    type named `iterator_category' in `class std::vector<double,
    std::allocator<double> >'
---

[-- Attachment #2: minifail.ii.bz2 --]
[-- Type: application/bzip2, Size: 32206 bytes --]

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

* Re: Compilation of <vector> and self-defined 'distance(a,b)' fails
  2004-05-26  6:59 Compilation of <vector> and self-defined 'distance(a,b)' fails Benjamin King
@ 2004-06-01  1:29 ` Jim Wilson
  0 siblings, 0 replies; 2+ messages in thread
From: Jim Wilson @ 2004-06-01  1:29 UTC (permalink / raw)
  To: Benjamin King; +Cc: gcc-bugs

Benjamin King wrote:
> I think my gcc has a bug. It fails to compile the following program. 
> Renaming 'distance' to anything else solves this, so I guess that the 
> 'distance' function from <iterator> somehow escaped the std::-namespace.

Filing bug reports into our bugzilla bug tracking database is better 
than sending mail to gcc-bugs, as we don't track bug reports mailed to 
the list.  The result is that you are more likely to get a useful 
response if you use bugzilla.  See
     http://gcc.gnu.org/bugs.html
for more info on reporting bugs.

I am not a C++ expert, so I am really not the right person to be looking 
at this.  However, I suspect the problem is that the vector class is 
itself defined in namespace std, and uses the iterator classes, and that 
is somehow causing the search for the distance function to also look at 
the interator classes.  It isn't just the name distance, any name in 
stl_interator.h seems to cause the same problem.

I can get your testcase to compile if I change
   d = distance(v, v);
to
   d = ::distance(v, v);
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com


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

end of thread, other threads:[~2004-06-01  1:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-26  6:59 Compilation of <vector> and self-defined 'distance(a,b)' fails Benjamin King
2004-06-01  1:29 ` Jim Wilson

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