www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/09/10:17:36

From: Charles Krug <charles AT pentek DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: DJGPP -> possible bug
Date: Fri, 09 Jan 1998 09:34:33 -0500
Lines: 28
Message-ID: <34B63578.91618208@pentek.com>
References: <34B50E12 DOT 441C AT oce DOT nl>
NNTP-Posting-Host: mail.pentek.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

A. Jans-Beken wrote:

> As an exercise I made my own string class (from the book of Stroustrup).
> I wrote a testprogram too and it appears that the operator+= results in
> an abnormal program termination.
>

You didn't supply your += operator, so let me guess--you're not reallocating
your string when you change its length.  When you get to the end of your
string buffer, you start overwriting memory that doesn't belong to you, with
"unpredictable and undesirable" results.

Take a look at your += operator, and make sure you're handling your memory
allocation correctly.  You may find it useful to make a member method to
handle memory allocation and call it from all the appropriate places.





--
Charles Krug, Jr.
Application Engineer
Pentek Corp
1 Park Way
Upper Saddle River, NJ 07458


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019