Created on 2023-01-07.00:00:00 last changed 3 weeks ago
Consider:
#include <source_location> inline char *f() { static char array[std::source_location::current().line()]; return array; }
The sequence of tokens comprising the definition of f can appear in multiple translation units, on different lines. The one-definition rule is not violated. Thus, there is a single function f in the program with a unique static local object array, but that object would have a different type in each translation unit. It is unclear how to implement this, absent the conservative approach of always returning a value-initialized object from std::source_location::current, which would defeat its purpose.
Possible approaches to resolve this issue might include:
2023-01-08
Forwarded to LWG / LEWG, by decision of the CWG chair.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-01-07 00:00:00 | admin | create |