This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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$


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]