From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11219 invoked by alias); 4 May 2007 23:11:12 -0000 Received: (qmail 11180 invoked by uid 48); 4 May 2007 23:11:02 -0000 Date: Fri, 04 May 2007 23:11:00 -0000 Message-ID: <20070504231102.11179.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug libstdc++/31825] bug in g++ a.out for stl::map In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "pcarlini at suse dot de" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-05/txt/msg00426.txt.bz2 ------- Comment #2 from pcarlini at suse dot de 2007-05-05 00:11 ------- You are only passing around a pointer to name and not allocating memory for the various "C" strings, instead overwriting each time in the loop the same char array. Well, there are also other problems in the code, like not passing to std::map as third template argument an appropriate comparison object: struct ltstr { bool operator()(const char* s1, const char* s2) const { return std::strcmp(s1, s2) < 0; } }; I would suggest always using std::string, instead of "C" strings, at least while you are still learning std::map. -- pcarlini at suse dot de changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31825