This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/53215] New: Warn if orphaned memory is created by ignoring return value of new
- From: "ssprog1 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 03 May 2012 17:38:23 +0000
- Subject: [Bug c++/53215] New: Warn if orphaned memory is created by ignoring return value of new
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53215
Bug #: 53215
Summary: Warn if orphaned memory is created by ignoring return
value of new
Classification: Unclassified
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: ssprog1@gmail.com
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;
}
Request: g++ should report a compile-time warning message for such a memory
leak. Currently, no warning is output:
user@quant:/tmp$ g++ -Wall -Wextra MemoryLeakCheckCompilerWarning.cpp
-o MemoryLeakCheckCompilerWarning.exe
user@quant:/tmp$