Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

Memory leak: Temporary std::set is not deleted.

$
0
0

The following program:

 

#include <set>
#include <iostream>

std::set<std::string> Foo() {

  std::set<std::string> ret;
  ret.insert("test");
  return ret;
}

int main(int argc, char** argv) {

  while (true) {
    for(auto& s : Foo()) {
      // do nothing.
    }
  }

  return 0;
}

Leaks memory and causes my system to swap after a few seconds. This is on Linux x86_64, ICC Version 17.0.1, GCC Version 6.3.0. I compile like this:

icpc -o test test.C

Compiling the same program with g++ does not show this leak. Any ideas? Is there a bug in the compiler?

Thread Topic: 

Bug Report

Viewing all articles
Browse latest Browse all 1175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>