Heap on Mac and Linux
#Linux #Mac #C++
Some caveats about heap on mac and linux
#include <iostream>
int main() {
double *a = new double[5];
for(auto i = 0; i < 5; i++)
{
a[i] = i;
}
std::cout << a[-10] << std::endl;
}
This program runs on Mac without warning or error. However, it gives segmentation fault (core dump) error on ubuntu and cent os.
Published:
by Lei Ma;
Table of Contents
Current Ref:
- til/programming/cpp/cpp-heap-mac-linux-diff.md