From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32893 invoked by alias); 11 Oct 2015 23:20:25 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 32859 invoked by uid 48); 11 Oct 2015 23:20:21 -0000 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/67927] New: array new expression with excessive number of elements not diagnosed Date: Sun, 11 Oct 2015 23:20:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-10/txt/msg00833.txt.bz2 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.)