Open cor3ntin opened 1 month ago
@llvm/issue-subscribers-clang-frontend
Author: cor3ntin (cor3ntin)
Note that gcc currently puts the resulting initializer_list constant in non-mergeable rodata for locals. I'm not sure if this is a reaction to the constexpr evaluation rules, or something else.
Related fun: the following prints "0 1" in gcc. We should make sure we don't do the same thing.
#include <initializer_list>
#include <cstdio>
static constexpr std::initializer_list<char> a = {'b','c','\0'};
static constexpr std::initializer_list<char> b = {'b','c','\0'};
int main() {
const char* volatile aaa = a.begin();
const char* volatile bbb = b.begin();
printf("%d %d\n", a.begin() == b.begin(), aaa == bbb);
}
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2752r3.html