The following UB is not caught by gcc: #include <vector> constexpr auto tester() { std::vector<int> v = {1, 2, 3}; auto p = &v[v.size() + 1]; return &v[0] == p; } static_assert(!tester()); https://godbolt.org/z/Y3ofcb1b1
Confirmed reduced testcase: ``` #define size 3 constexpr auto tester() { int *v = new int[size]; auto p = &v[size+1]; bool t = &v[0] == p; delete[] v; return t; } static_assert(!tester()); #if 0 constexpr auto tester1() { int v[size]; auto p = &v[size+1]; bool t = &v[0] == p; return t; } static_assert(!tester1()); #endif ``` GCC does catch the static allocated one; just not the dynamic allocated one.
.