www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/08/05/09:39:46

Date: Mon, 5 Aug 1996 13:20:45 BST
From: "C. N. Feng" <fengcn AT essex DOT ac DOT uk>
Subject: Re: Internal compiler error, Help!
To: DJGPP <djgpp AT delorie DOT com>
Message-Id: <ECS9608051345A@essex.ac.uk>
Mime-Version: 1.0

On Thu, 1 Aug 1996 13:48:52 +0300 (GMT) Salvador Eduardo Tropea (SET) wrote:
> 
> Hi Feng:
> 
> >"C. N. Feng" <fengcn AT essex DOT ac DOT uk> wrote:
> >>Hi,
> >>I encountered an "Internal compiler error". But I cannot see any wrong with my code.

> >There you go - it's not your fault, it's GNUs. Send this message to
> >the address they mention and see what happens.
> >As a temporary fix, try just rearranging your function - keep it doing
> >the same thing, in slightly different ways, to avoid this compiler
> >bug. Perhaps they'd like it if you sent the rearrangement that worked
> >to the above address as well... it might help in killing the bug?
>   
>   Are you using Windows or CWSDPMI? Some versions of CWSDPMI don't support lotz 
> malloc calls and the compiler use to crash with this stupid message.
>   Are you trying to put a really huge static array in your code? Another weak 
> point of the package.
>   Do you have the default 256Kb stack size? some people use more.
>   If you allready checked all of this send the bug report to the GNU people.
> 
> bye SET
> 

Thanks  for all  your suggestions.
I think I found the problem that is you cannot use the exceptions in a base class.
I don't know whether it is a bug or an unsported feature. An example is followed.

Feng, Cheng-Ning

// ************************************************************************
#include<iostream.h>
#include<stdlib.h>

class Ele
{       public:
        Ele();
        ~Ele();
        
        Ele& Setup(int n);

        private:
        int *data;
};

Ele::Ele():data(NULL){}
Ele::~Ele(){  delete [] data;}
Ele& Ele::Setup(int n)
{       try
        {       data=new int[n];
                if(!data)       throw("error in locate memory of class Ele");
        }
        catch(char *error)
        {       cerr<<error<<endl;exit(1);};
        return (*this);
}

class Com
{       public:
        Com();
        ~Com();

        Com& Setup(int n);

        private:
        Ele *data;
};
Com::Com():data(NULL){}
Com::~Com(){      delete [] data;}

// 'internal compiler error' when using this definition

Com& Com::Setup(int n) 
{       try
        {       data=new Ele[n];
                if(!data)
                        throw("error in locate memory of class Com");
        }
        catch(char *error){       cerr<<error<<endl;exit(1);};
        return (*this);
}

// undefined reference to 'terminate(void)' when using this definition
/*
Com& Com::Setup(int n) 
{       data=new Ele[n];
        if(!data)       exit(1);
        return (*this);
}
*/

/* commend line
        gcc -fhandle-exceptions -o test.exe test.cc -liostr
*/
int maint(void)
{       Com D;
        D.Setup(5);

        return 0;
}



- Raw text -


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