public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55446] New: array new with size zero vanishes from object code
@ 2012-11-23 10:49 jens.maurer at gmx dot net
  2012-11-23 22:21 ` [Bug c++/55446] " daniel.kruegler at googlemail dot com
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: jens.maurer at gmx dot net @ 2012-11-23 10:49 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55446

             Bug #: 55446
           Summary: array new with size zero vanishes from object code
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jens.maurer@gmx.net
              Host: x86_64-unknown-linux-gnu
            Target: x86_64-unknown-linux-gnu


The following program compiles successfully and outputs nothing at all.  In
fact, the generated assembly has an empty "main".  This happens even when
compiling with -O0.

#include <iostream>

struct S {
  S() { }
};

int main()
{
  std::cout << new S[0] << " bla" << std::endl;
}

$  g++ new-opt.cc -Wall -Wextra 
$ ./a.out 
(no output)

The issue goes away when removing the default constructor of "S".  It seems gcc
believes array-new with zero size is undefined behavior and thus removes the
rest of the expression.  I can't follow the "undefined behavior" part;
array-new with zero size should yield a non-zero pointer (see 3.7.3.1p2
[basic.stc.dynamic.allocation] and 5.3.4p7 [expr.new]).


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

end of thread, other threads:[~2013-01-30 10:19 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-23 10:49 [Bug c++/55446] New: array new with size zero vanishes from object code jens.maurer at gmx dot net
2012-11-23 22:21 ` [Bug c++/55446] " daniel.kruegler at googlemail dot com
2012-11-23 22:28 ` paolo.carlini at oracle dot com
2012-11-23 22:29 ` paolo.carlini at oracle dot com
2012-11-24  0:30 ` paolo.carlini at oracle dot com
2012-11-24  1:24 ` [Bug c++/55446] [4.7/4.8 Regression] " paolo.carlini at oracle dot com
2012-11-24  1:53 ` paolo.carlini at oracle dot com
2012-11-24  1:54 ` paolo.carlini at oracle dot com
2012-11-24  9:28 ` harald at gigawatt dot nl
2012-11-24  9:33 ` paolo.carlini at oracle dot com
2012-11-24 10:04 ` paolo.carlini at oracle dot com
2012-11-24 11:27 ` harald at gigawatt dot nl
2012-11-24 23:46 ` paolo at gcc dot gnu.org
2012-11-24 23:55 ` paolo at gcc dot gnu.org
2012-11-24 23:56 ` paolo.carlini at oracle dot com
2013-01-30 10:19 ` paolo.carlini at oracle dot com

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