This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug c++/12446] New: Dereferencing iterators
- From: "mjw at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Thu, 27 Jan 2011 15:58:26 +0000
- Subject: [Bug c++/12446] New: Dereferencing iterators
- Auto-submitted: auto-generated
http://sourceware.org/bugzilla/show_bug.cgi?id=12446
Summary: Dereferencing iterators
Product: gdb
Version: archer
Status: NEW
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned@sourceware.org
ReportedBy: mjw@redhat.com
It would be nice if iterators could be dereferenced through ->.
Currently only * works.
Using -> will give a "There is no member or method" error.
Example:
$ cat foo.cpp
#include <vector>
#include <string>
#include <iostream>
int main(int argc, char **argv)
{
std::pair<std::string, std::string> p ("first", "second");
std::vector<std::pair<std::string, std::string> > v;
v.push_back (p);
std::vector<std::pair<std::string, std::string> >::iterator it = v.begin ();
std::cout << it->first << " : " << it->second << std::endl;
return 0;
}
$ g++ -g -o foo foo.cpp
$ gdb ./foo
GNU gdb (GDB) Fedora (7.2-36.fc14)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /tmp/foo...done.
(gdb) break main
Breakpoint 1 at 0x400d74: file foo.cpp, line 7.
(gdb) run
Starting program: /tmp/foo
Breakpoint 1, main (argc=1, argv=0x7fffffffe278) at foo.cpp:7
7 std::pair<std::string, std::string> p ("first", "second");
(gdb) n
8 std::vector<std::pair<std::string, std::string> > v;
(gdb)
10 v.push_back (p);
(gdb)
12 std::vector<std::pair<std::string, std::string> >::iterator it =
v.begin ();
(gdb)
14 std::cout << it->first << " : " << it->second << std::endl;
(gdb) print it->first
There is no member or method named first.
(gdb) print (*it).first
$1 = "first"
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.