pythontutor-dev / pythontutor

11 stars 4 forks source link

#NullTrace in C++ function call, but works if contents inlined into main #7

Open pgbovine opened 4 years ago

pgbovine commented 4 years ago

C++

#include<iostream>
using namespace std;

// results in #NullTrace but works when func's contents are INLINED into main
void func() {
  int *p, *numbers;
  p=numbers=new int[10];
  *p=782;
  *p+=2;
  *(p+2)=59;
  p++;
  *(p)=503;
  *(p)+=1;
  for(int n=0; n<3; n++)
   cout<<numbers[n]<<",";
  delete p;
}

int main() {
  func();
  return 0;
}