Semantics of local PROGMEM I want to create a class to better use strings in flash. At its core is the following

template&lt;size_t N&gt;
struct progstr
{
    constexpr progstr(const char (&amp;str)[N])
        : progstr(str, make_index_sequence&lt;N&gt; {}) {}

    template&lt;size_t... Is&gt;
    constexpr progstr(const char (&amp;str)[N], index_sequence&lt;Is...&gt;)
        : _str{str[Is]...} {}

    constexpr operator const char*() const {
        return _str;
    }

    const char _str[N] PROGMEM;
};


Where make_index_sequence and index_sequence are the same as those from &lt;utility&gt;.

The problem arises when I try to emulate PSTR

template&lt;size_t N&gt;
constexpr const char* pstr(const char (&amp;str)[N])
{
    return progstr&lt;N&gt;{str};  // huh?
}


It even compiles. However


The returned pointer is "dangling", but it is pointing into flash memory. Will this work?
A constexpr function may be called with an array with runtime values, and that cannot possibly create the string in flash can it?
I tested with 100 chars string 

const char*

Sketch uses 1566 bytes
Global variables use 288 bytes


with F macro

Sketch uses 1594 bytes
Global variables use 188 bytes


progstr &lt;101> ps(...

Sketch uses 1618 bytes 
Global variables use 288 bytes


const char* ps = pstr("...

Sketch uses 1502 bytes 
Global variables use 188 bytes


the pstr version string has errors at the end, when printed.

sorry, the pstr function works only if previous sketch version put the string into flash memory. it is not in hex file.