jflegert
December 13th, 2002, 12:04 PM
I was trying to use new and nothrow (using VC7) and could not get it to compile. I tried using the following example from MSDN:
// new_and_delete.cpp
// compile with: /EHsc
#include <stdio.h>
#include <new.h>
#include <limits.h>
int main()
{
int * i_arr;
try {
i_arr = new int[UINT_MAX]; // vector new
}
catch(...) {
printf("caught exception\n");
}
int * k_arr;
k_arr = new (std::nothrow) int[UINT_MAX]; // allocation will fail
delete[] i_arr; // vector delete
delete[] k_arr;
}
and I get the following compilation errors:
c:\AIT\vc\test\test\testDlg.cpp(242) : warning C4307: '*' : integral constant overflow
c:\AIT\vc\test\test\testDlg.cpp(249) : error C2061: syntax error : identifier 'nothrow'.
Any suggestions?
I don't really have a specific reason for using nothrow, I just came across it while reading.
Thanks,
John Flegert
// new_and_delete.cpp
// compile with: /EHsc
#include <stdio.h>
#include <new.h>
#include <limits.h>
int main()
{
int * i_arr;
try {
i_arr = new int[UINT_MAX]; // vector new
}
catch(...) {
printf("caught exception\n");
}
int * k_arr;
k_arr = new (std::nothrow) int[UINT_MAX]; // allocation will fail
delete[] i_arr; // vector delete
delete[] k_arr;
}
and I get the following compilation errors:
c:\AIT\vc\test\test\testDlg.cpp(242) : warning C4307: '*' : integral constant overflow
c:\AIT\vc\test\test\testDlg.cpp(249) : error C2061: syntax error : identifier 'nothrow'.
Any suggestions?
I don't really have a specific reason for using nothrow, I just came across it while reading.
Thanks,
John Flegert