www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/05/14:16:42

From: amark AT luckynet DOT co DOT il
Newsgroups: comp.os.msdos.djgpp
Subject: Re: This should run fine... but doesn't ?? Arrrggghhh!!
Date: Sun, 05 Apr 1998 13:02:51 -0600
Organization: Deja News - The Leader in Internet Discussion
Lines: 76
Message-ID: <6g8h0c$ut3$1@nnrp1.dejanews.com>
References: <35230BC3 DOT 1615308F AT hydra12 DOT ae DOT su DOT oz DOT au>
NNTP-Posting-Host: 192.115.13.10
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <35230BC3 DOT 1615308F AT hydra12 DOT ae DOT su DOT oz DOT au>,
  "Eric J. Whitney" <whit_e AT hydra12 DOT ae DOT su DOT oz DOT au> wrote:
>
> Hi folks.... thought I'd bother you all with a problem I've been having
> for some time.
>
> I have a C++ program, which #includes my own Array and Matrix template
> classes.  These work by using one pointer which points to the top of the
> data.  They also have various associated exception classes which they
> can throw.
>
> The main program initialises one <float> instance say:  Matrix<float>
> myMatrix(3, 3);
> Then there is a second instance ie:  Matrix<float> mySecondMatrix(3,
> 3);  which appears further down the program listing ie:
>
> Matrix<float> myMatrix(3, 3);
>
> .....  Do some stuff here .....
>
> Matrix<float> mySecondMatrix(3, 3);
>
> ...  More stuff....
>
> Now:  This compiles & links fine in DJGPP C++ using RHIDE.  but when I
> run it it gives me a "program exit code 255"  followed by all this
> stuff:
>
> Call frame traceback:
> In function free+14
> In function __builtin_delete+16
> In functon __builtin_vec_delete+11
> es.cpp(153) in function SetSize_t5Array1ZfUs
> es.cpp(17) in function __t5Array1ZfUs
> es.cpp(142) in function main
> in function __crt1_startup+138
>
> What have I done wrong???   It runs fine with one instance of the
> Matrix, but for two, it crashes!!!
> I have stepped through it using F8 and it always crashes right where the
> second matrix is initialised.
>
> HELP!
>
> --
> Eric "The Wingnut" Whitney
> <whit_e AT hydra12 DOT ae DOT su DOT oz DOT au>
>
________________________________________________________________________

  You have to supply all the sorce to enable the real debugging,
neverless I may try to make an uneducated guess:

1. The "C-like" usage of the keyword "static" in C++ -
static element of the class is common element (allocated only once)
for all instanses (objects) of the class, static member functions
change their values. You may have used the static element without any
need.
2. The compiling options are very important, when compiling templates -
check em, or place all the template's body in the header file(s).
3. Check the allocation (new) in the constractor - some
errors there cath up only from the repeted usage.
4. May be in the compiler, you use, repeted declaration Matrix<float>,
Matrix<float> creates two equel classes - the bug. Try :
typedef Matrix<float> FMatrix;
> FMatrix myMatrix(3, 3);
>
> .....  Do some stuff here .....
>
> FMatrix mySecondMatrix(3, 3);

(http://www.luckynet.co.il/~amark/)
(http://www.luckynet.co.il/~amark/Etp103.exe)

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading

- Raw text -


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