Is a string literal in С++ created in static memory?

Yes, string literals are valid for the entire duration of the program, even during the destruction of static objects.

2.13.4/1 in the Standard says

An ordinary string literal has type “array of n const char” and static storage duration.

The Standard says of ‘static storage duration’ in 3.7.1/1:

The storage for these objects shall last for the duration of the program.

Leave a Comment