This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Missing compile-time warning for orphaned memory
- From: Samuel David <ssprog1 at gmail dot com>
- To: gcc at gnu dot org, libstdc++ at gcc dot gnu dot org
- Date: Thu, 3 May 2012 12:16:26 -0400
- Subject: Re: Missing compile-time warning for orphaned memory
- References: <CAKD23Nmqb7R2nZ5XGtQVXX8aWcwyiYGQ+bFszc=jaJBoTEdpUg@mail.gmail.com>
Hi gcc team,
The following code creates orphaned memory by ignoring the return value of new:
#include<iostream>
using namespace std;
int main ( void ) {
for (int i=0; i< 10000000; i++)
new int[10000000];
int a;
cin >> a;
return 0;
}
Should g++ report a compile-time warning for this case?
root@quant:/tmp# g++ -Wall -Wextra MemoryLeakCheckCompilerWarning.cpp
-o MemoryLeakCheckCompilerWarning.exe
root@quant:/tmp#
Warm regards,
-S