public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "areza123 at yahoo dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/14410] New: Bug with implementation of set for const iterators in g++ ... Date: Wed, 03 Mar 2004 16:11:00 -0000 [thread overview] Message-ID: <20040303161106.14410.areza123@yahoo.com> (raw) On g++ compiler extracted from cygwin, I found the following inconsistencies in the implementation of set. If I have a const container, then the compiler should flag of a compilation *error* on an attempt to access elements using a non-const iterator. Hence, if I instantiate the print_elements method (which uses a non const iterator ) pos, I expect it to be *flagged* of as a compilation error. This is not what happens. #include <iostream> #include <set> using namespace std; template <typename T> void print_elements(const T & t, const char * print_header) { cout << print_header << endl; typename T::iterator pos; for (pos = t.begin(); pos != t.end(); ++pos) { cout << *pos << endl; } } This works perfectly fine if I instantiate using T as set<int> shown below. This is *incorrect*. int main() { set<int> col1; for (int i = 0; i <=5; ++i) { col1.insert(i); } print_elements(col1, "initialized: "); return 0; } Could somebody explain ? BTW - compiler behaves as expected *flagging* off errors for other container's like deque, etc. gcc --version 2.95.3-5 system type - Windows 2000 Professional complete command line that triggers the bug - g++ bugged_prog.cc -- Summary: Bug with implementation of set for const iterators in g++ ... Product: gcc Version: 2.95.3 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: areza123 at yahoo dot com CC: areza123 at yahoo dot com,gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14410
next reply other threads:[~2004-03-03 16:11 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-03-03 16:11 areza123 at yahoo dot com [this message] 2004-03-03 16:20 ` [Bug libstdc++/14410] " bangerth at dealii dot org 2004-03-04 0:45 ` reichelt at gcc dot gnu dot org 2004-03-04 1:12 ` pcarlini at suse dot de 2004-03-05 8:51 ` reichelt at igpm dot rwth-aachen dot de 2004-03-05 9:04 ` pcarlini at suse dot de 2004-03-20 21:58 ` reichelt at gcc dot gnu dot org 2005-01-17 12:07 ` pcarlini at suse dot de
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20040303161106.14410.areza123@yahoo.com \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).