The following code compiles with gcc and MSVC, but not with clang.
#include <array>
#include <vector>
consteval void foo(auto func) {
std::array<int, func().size()> f;
}
int main() {
foo([](){ return std::vector<int>{1,2,3,4,5};});
}
If I understand the rules of dynamic memory allocation in constant expressions correctly, this should be allowed because the memory is deallocated immediately. Is this a bug in clang? Or even undefined behaviour?