This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/67927] New: array new expression with excessive number of elements not diagnosed
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 11 Oct 2015 23:20:20 +0000
- Subject: [Bug c++/67927] New: array new expression with excessive number of elements not diagnosed
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67927
Bug ID: 67927
Summary: array new expression with excessive number of elements
not diagnosed
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
This is similar to bug 67913.
A new expression is considered erroneous if the value of the expression in its
noptr-new-declarator is such that the size of the allocated object would exceed
the implementation-defined limit (it's safe to assume that the limit doesn't
exceed the size of the address space). If the expression is a constant
expression, the program is ill-formed. The following program is not diagnosed
by GCC even though it contains two such ill-formed expressions.
void* operator new[] (unsigned long, void *p) { return p; }
void foo (void)
{
char c [1];
new int [__SIZE_MAX__];
new (c) int [__SHRT_MAX__][__SHRT_MAX__];
}
(Clang diagnoses the first but not the second, even though both expressions are
invalid; the second one for other reasons besides exceeding the
implementation-defined size limit.)