title: how do compilers assign memory addresses to variables?
body: <p>I teach a course where students get to ask questions about programming (!): I got this question:</p>
  
  <blockquote>
    <p>Why does the machine choose were variables go in memory? Can we tell
    it where to store a variable?</p>
  </blockquote>
  
  <p>I don't really know what to say. Here's my first attempt:</p>
  
  <blockquote>
    <p>The compiler (not the machine) chooses where to store the variables in the process address 
    space automatically. Using C, we cannot tell the machine where to store variables.</p>
  </blockquote>
  
  <p>But that "automatically" is somewhat anticlimactic and begs the question... and I've realized I don't even know if it's the compiler or the runtime or the OS or who does the assignment. Maybe someone can answer the student's question better than me.</p>