The C++ Standard does not say where string literals should be stored. It does however guarantee that their lifetime is the lifetime of the program. Your code is therefore valid.
More Related Contents:
- What is the lifetime of a static variable in a C++ function?
- Unicode encoding for string literals in C++11
- What is the lifetime of the result of std::string::c_str()?
- “Life-time” of a string literal in C
- Single quotes vs. double quotes in C or C++
- Lifetime of temporaries
- C++ multiline string literal
- How can I get double quotes into a string literal?
- String Literal address across translation units [duplicate]
- “constructing” a trivially-copyable object with memcpy
- Why are string literals l-value while all other literals are r-value?
- Computing length of a C string at compile time. Is this really a constexpr?
- lifetime of a std::initializer_list return value
- C++ warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
- using \ in a string as literal instead of an escape
- What does the symbol \0 mean in a string-literal?
- How to use Macro argument as string literal?
- C/C++, can you #include a file into a string literal? [duplicate]
- C++ constant reference lifetime (container adaptor)
- Why does gcc allow char array initialization with string literal larger than array?
- String literals not allowed as non type template parameters
- Comparing character arrays and string literals in C++
- Concat two `const char` string literals
- C++ Comparison of String Literals
- Why do (only) some compilers use the same address for identical string literals?
- Unary plus (+) against literal string
- Is it safe to make a const reference member to a temporary variable?
- Where are string literals stored, and can I modify them?
- cout
- How can I remove/refactor a «friend» dependency declaration properly?