Summary: | Out of bounds pointer arithmetic for dynamic allocated arrays not caught in constexpr | ||
---|---|---|---|
Product: | gcc | Reporter: | Jeremy R. <llvm> |
Component: | c++ | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | NEW --- | ||
Severity: | normal | CC: | daniel.kruegler, mpolacek, webrown.cpp |
Priority: | P3 | Keywords: | accepts-invalid |
Version: | unknown | ||
Target Milestone: | --- | ||
See Also: | https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97230 | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2023-08-30 00:00:00 | |
Bug Depends on: | |||
Bug Blocks: | 55004 |
Description
Jeremy R.
2023-08-30 16:51:25 UTC
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. . |