public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/67927] New: array new expression with excessive number of elements not diagnosed
@ 2015-10-11 23:20 msebor at gcc dot gnu.org
  2015-10-14  0:11 ` [Bug c++/67927] " msebor at gcc dot gnu.org
  2015-10-19 22:54 ` msebor at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2015-10-11 23:20 UTC (permalink / raw)
  To: gcc-bugs

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.)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-19 22:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-11 23:20 [Bug c++/67927] New: array new expression with excessive number of elements not diagnosed msebor at gcc dot gnu.org
2015-10-14  0:11 ` [Bug c++/67927] " msebor at gcc dot gnu.org
2015-10-19 22:54 ` msebor at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).