cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/14/14:30:26

From: wjae AT plex DOT nl (Wiel Aerts)
Newsgroups: comp.os.msdos.djgpp
Subject: does new throws exceptions?
Date: Sun, 14 Jun 1998 18:00:05 GMT
Organization: Plex -- a public access Internet provider
Lines: 30
Message-ID: <35840cf4.12845170@news.plex.nl>
NNTP-Posting-Host: news.plex.nl
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I tried to use exceptions with the following small piece of
code. It compiles without problems (gcc 2.8.1).

#include <iostream>
#include <new>

int main()
{
        char * p;
        try {
                 p = new char[0xFFFFFFF];
        }
        catch (bad_alloc& f) {
                cerr << "wrong: " << f.what() << endl;
        }
        return 0;
}

Running the program gives the output:

Virtual memory exceeded in `new'

Of course this is correct but the line is not generated
in the catch block.
What happens? What I am doing wrong?

Thanks in advance for your help.

ps: If I throw an exception by myself in
some function then all seems to work fine.

- Raw text -


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