[Bug c++/53215] New: Warn if orphaned memory is created by ignoring return value of new

ssprog1 at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu May 3 17:38:00 GMT 2012


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$



More information about the Gcc-bugs mailing list