This is the mail archive of the gcc@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]

Re: Missing compile-time warning for orphaned memory


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


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