delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/08/13:02:01

Newsgroups: comp.os.msdos.djgpp
From: "A. Jans-Beken" <jabe AT oce DOT nl>
Subject: DJGPP -> possible bug
Message-ID: <34B50E12.441C@oce.nl>
Sender: news AT oce DOT nl (The Daily News @ nntp01.oce.nl)
Organization: Océ-Nederland B.V.
Mime-Version: 1.0
Date: Thu, 8 Jan 1998 17:34:10 GMT
Lines: 29
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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. 

In my test program I included a loop to execute the += operator several
times. The problem is that the program crashes after two cycles, but
when I want to trace (with debug under RHIDE) this happens not every
time at the same cycle. Furthermore I inspected all variables involved
and none gives me suspicious results.

Is this a known problem?

Send me an e-mail if you want to see my complete code (too long to put
it all here). The loop-snippet is here:

   cout << "Creating strings: \"Test_1\" ... \"Test_9\".\n";

   STRING a[10];
   char asc[] = {'x','\0'};
   char *as = &asc[0];

   for (int i = 0; i < 10; i++) {
      asc[0] = i + '0';
      a[i] = "Test_";
      a[i] += as;	// <--- Here program crashes.
      cout << a[i] << "\n";
      }

please help

- Raw text -


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