delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/02/13:23:51

Message-Id: <359BC1BC.2952DB5B@cpd.ufsm.br>
Date: Thu, 02 Jul 1998 14:22:04 -0300
From: Leonardo Brondani Schenkel <schenkel AT cpd DOT ufsm DOT br>
Organization: Centro de Processamento de Dados - UFSM
Mime-Version: 1.0
To: djgpp AT delorie DOT com
Subject: problem with new

I'm using GCC and G++ 2.81 and I would like to know if its
implementation of new conforms with the ISO/ANSI C++ draft. The
following code 
does not work:

#include <iostream>
#include <new>

int main()
{
    try
    {
        char *ptr = new char[100000000];    // this will probably fail
        cout << ptr << endl;
    }
    catch(...)
    {
        cout << "exception!" << endl;
    }

    return 0;
}

	The result is:
	"new: virtual memory exhausted" (or something like that...)
	And this code does not compile:

#include <iostream>
#include <new>

int main()
{
    try
    {
        char *ptr = new(char[100000000], nothrow);	// this will probably
fail
        cout << ptr << endl;
    }
    catch(...)
    {
        cout << "exception!" << endl;
    }
    return 0;
}

	The compiler generates a "parse error before ,", like nothrow hasn't
been defined.

	Thanks in advance,
-- 
=================================================
Leonardo Brondani Schenkel <schenkel AT cpd DOT ufsm DOT br>
http://www.inf.ufsm.br/~schenkel/
ICQ: 14608496
-------------------------------------------------
Centro de Processamento de Dados
Universidade Federal de Santa Maria
Santa Maria, RS
Brasil
=================================================

- Raw text -


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