title: location of variable changing?
body: <p>I have some code, but for some reason the location of a variable changes in the middle of my code.
  In my main I read one integer from stdin, then malloc an array of structs.</p>
  
  <pre><code>int main(){
      int numcities;
      scanf("%d", &amp;numcities);
  
      City **cities = malloc(numcities*sizeof(City)*2); //*2 is just to be sure, gonna remove that later.
  
      for(int n = 0;n&lt;numcities;n++){
          int nularr[numcities];
          for(int n2 = 0;n2&lt;numcities;n2++){
              nularr[n2] = 0;
          }
          City c = {
              .value = 1,
              .options = nularr,
          };
          cities[n] = &amp;c;
      };
  
      readRoads(cities, numcities);
  }
  </code></pre>
  
  <p>readRoads is shown below. before calling readRoads I can access numcities (gdb and inside the code), but after it sigsegvs when trying to use it, and in gdb complains about not being able to read memory at 0xffffffcd.
  If I take a pointer to numcities and dereference it later, everything is intact. but getting the pointer after calling readRoads gives me 0xffffffcd (consistently) which is unreadable.
  I already receive twice as much memory from malloc as necessary, </p>
  
  <pre><code>void readRoads(City **cities, int N){
      for(int n = 0;n&lt;N;n++){
          int buf;
          int res[N];
          int roads = 0;
          City *options[N];
          scanf("%d", &amp;buf);
          for(int r = 0;r&lt;N;r++){
              res[r]= buf &lt;&lt; r;
              if(res[r]){
                  options[roads] = cities[r];
                  roads++;
              }
          }
  
          cities[n]-&gt;id = n;
          cities[n]-&gt;name = n +'A';
          cities[n]-&gt;optionsCount = 1;
  
          for(int i = 0; i &lt; roads; i++){
              cities[n]-&gt;options[i] = options[i]-&gt;id;
          }
      }
  }
  </code></pre>