title: Where are string constants stored in memory?
body: <p>In a C++ program, where is constant data stored, especially string constants ?</p>
  
  <p>I am asking because in the following question:</p>
  
  <p><a href="https://stackoverflow.com/questions/40377546/why-can-creating-a-static-const-stdstring-cause-an-exception/40377626?noredirect=1#comment68029147_40377626">Why can creating a static const std::string cause an exception?</a></p>
  
  <p>The answer by Damon, has the following at the end:</p>
  
  <blockquote>
    <p>A string_view will, contrary to a string, not allocate non-constant
    memory, copy constant data into that, and then pretend it's constant.
    Instead, it will manage a pointer directly to the constant data, and
    that's all.</p>
    
    <p>That way, your constants are truly (not just formally) constant, there
    are no allocations, no possibility of exceptions, and no double memory
    usage. And for the most part, it still looks and smells like a string.
    The only notable differences being that a string_view doesn't
    guarantee nul-termination (but the character constant it points to
    does, so this is irrelevant), and the fact that it's really constant,
    not modifiable... which is exactly what you want.</p>
  </blockquote>
  
  <p>Dont even the constants need to be stored in memory some where ? And if they are stored in memory (since memory is finite), isn't it possible an exception can be thrown because there is no more memory ?</p>