[Bug c++/53330] new() operator can return NULL on a zero-length allocation

2015-08-12 Thread paolo at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53330

--- Comment #4 from paolo at gcc dot gnu.org paolo at gcc dot gnu.org ---
Author: paolo
Date: Wed Aug 12 22:38:04 2015
New Revision: 226840

URL: https://gcc.gnu.org/viewcvs?rev=226840root=gccview=rev
Log:
2015-08-12  Paolo Carlini  paolo.carl...@oracle.com

PR c++/53330
* g++.dg/init/new42.C: New.

Added:
trunk/gcc/testsuite/g++.dg/init/new42.C
Modified:
trunk/gcc/testsuite/ChangeLog


[Bug c++/53330] new() operator can return NULL on a zero-length allocation

2015-08-12 Thread paolo.carlini at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53330

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
  Known to work||4.9.0, 5.0
 Resolution|--- |WORKSFORME

--- Comment #5 from Paolo Carlini paolo.carlini at oracle dot com ---
I'm adding a testcase and closing the bug.


[Bug c++/53330] new() operator can return NULL on a zero-length allocation

2013-03-29 Thread kilobyte at angband dot pl


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



--- Comment #2 from Adam Borowski kilobyte at angband dot pl 2013-03-29 
13:13:21 UTC ---

Created attachment 29750

  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=29750

updated testcase



Updated testcase: it checks for invalid pointers (by freeing them), and returns

an exit code (if it won't crash first).


[Bug c++/53330] new() operator can return NULL on a zero-length allocation

2013-03-29 Thread kilobyte at angband dot pl


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



--- Comment #3 from Adam Borowski kilobyte at angband dot pl 2013-03-29 
13:20:53 UTC ---

Re-tested:

* gcc-4.7.2 works on amd64, armhf, x32, fails on i386

* gcc-4.8.0 works on all of the above

(all Debian)



So it appears to be fixed in 4.8, at least on architectures I tried. 

Regardless of whether you'll fix it in 4.7 or not, it may be worth adding to

the test suite.


[Bug c++/53330] new() operator can return NULL on a zero-length allocation

2012-05-12 Thread kilobyte at angband dot pl
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53330

--- Comment #1 from Adam Borowski kilobyte at angband dot pl 2012-05-12 
11:01:23 UTC ---
Correction: after testing with valgrind, the return value is indeed
uninitialized; the pointer in contructor-but-no-fields case happens to be
non-zero but is junk and will cause a crash when you try to free it.