title: Lifetime of literals in C
body: <p>There are a lot of good answers on this site regarding the static lifetime of string literals. As I understand it, they are allocated in read-only memory (others have referred specifically to a "string-literal pool"). As such, returning a pointer to a string literal would not result in a dangling pointer. They are also lvalues.</p>
  
  <p>Why does the same not hold for an integer constant literal? Does it not also have static storage duration? If I attempt to assign to an integer constant, gcc complains that it is not an lvalue.</p>
  
  <p>Why are string literals given this special treatment? (And compound literals in C99). I've heard the following definition for lvalues: "An lvalue (locator value) represents an object that occupies some identifiable location in memory (i.e. has an address)." If a string literal (a character array type) must be addressable in memory, why does the same not apply to an integer? Even an integer still has to be allocated in the program's address space. Is there a performance reason?</p>