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

icpc program fails with double free when it shouldn't

$
0
0

Hi

 

The following program fails with " double free or corruption" error. I believe it is a compiler bug. Could someone please have a look at it.

icpc version 14.0.1 (gcc version 4.7.0 compatibility)

icpc -std=c++11 -O2 -g streamtest.cpp

 

#include <iostream>
#include <stdio.h>
#include <sstream>

struct Path
{
   Path()
   {
      _host = "host";
      _dir =  "dir";
      _file = "file";
   }

   std::string host()
   {
      return _host;
   }

   std::string path() {

      std::string ret = host() + _dir + _file;
      return  ret;
   }

   private:
      std::string _dir;
      std::string _file;
      std::string _host;
};

int main () {

  Path path;
  std::string p = path.path();

  return 0;

}


Viewing all articles
Browse latest Browse all 1175

Trending Articles



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