public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13215] New: bad code generated to call operator new[] when -fcheck-new
@ 2003-11-28 11:51 tom at storagematrix dot com
  2003-11-28 13:14 ` [Bug c++/13215] " falk at debian dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: tom at storagematrix dot com @ 2003-11-28 11:51 UTC (permalink / raw)
  To: gcc-bugs

The code generated to call operator new[] causes a segmentation fault
when operator new[] returns 0 to indicate memory exhaustion.  

The code generated by GCC that calls operator new[] (with -fcheck-new)
increments the memory pointer returned by operator new[] by 4 *before*
comparing it to 0 to see if it should call the ctor.  The segmentation
fault occurs when the constructor is called.

---- sample.cpp ----
// g++ -g -fcheck-new -fno-exceptions sample.cpp   -o sample
#include <stdlib.h>

class foo {
public:
        int v;
        foo(){ v = 0; }
        ~foo() {}
        void* operator new[](size_t size) {
                return 0;                       // simulated memory failure
        }
        void operator delete[](void* p, size_t size) { }
};

main()
{
        foo *p = new foo[2];
        if (p) delete [] p;
        return 0;
}

---- EOF ----

How-To-Repeat:
$ g++ -fcheck-new -fno-exceptions sample.cpp -o sample
$ ./sample
Segmentation fault

-- 
           Summary: bad code generated to call operator new[] when -fcheck-
                    new
           Product: gcc
           Version: 3.2.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tom at storagematrix dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-redhat-linux
  GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux


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


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

* [Bug c++/13215] bad code generated to call operator new[] when -fcheck-new
  2003-11-28 11:51 [Bug c++/13215] New: bad code generated to call operator new[] when -fcheck-new tom at storagematrix dot com
@ 2003-11-28 13:14 ` falk at debian dot org
  2003-11-28 17:34 ` [Bug c++/13215] [3.3 only] " pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: falk at debian dot org @ 2003-11-28 13:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From falk at debian dot org  2003-11-28 13:14 -------
I can confirm this with 3.3, but it seems fixed in 3.4. As -fcheck-new is not
a frequently used option, I am not certain this will be fixed in 3.3.3...


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1


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


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

* [Bug c++/13215] [3.3 only] bad code generated to call operator new[] when -fcheck-new
  2003-11-28 11:51 [Bug c++/13215] New: bad code generated to call operator new[] when -fcheck-new tom at storagematrix dot com
  2003-11-28 13:14 ` [Bug c++/13215] " falk at debian dot org
@ 2003-11-28 17:34 ` pinskia at gcc dot gnu dot org
  2003-12-01  2:06 ` [Bug c++/13215] [3.3 Regression] " pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-11-28 17:34 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
            Summary|bad code generated to call  |[3.3 only] bad code
                   |operator new[] when -fcheck-|generated to call operator
                   |new                         |new[] when -fcheck-new
   Target Milestone|---                         |3.3.3


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


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

* [Bug c++/13215] [3.3 Regression] bad code generated to call operator new[] when -fcheck-new
  2003-11-28 11:51 [Bug c++/13215] New: bad code generated to call operator new[] when -fcheck-new tom at storagematrix dot com
  2003-11-28 13:14 ` [Bug c++/13215] " falk at debian dot org
  2003-11-28 17:34 ` [Bug c++/13215] [3.3 only] " pinskia at gcc dot gnu dot org
@ 2003-12-01  2:06 ` pinskia at gcc dot gnu dot org
  2003-12-21 21:47 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-01  2:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-01 02:06 -------
This is a regression from 2.95.3.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[3.3 only] bad code         |[3.3 Regression] bad code
                   |generated to call operator  |generated to call operator
                   |new[] when -fcheck-new      |new[] when -fcheck-new


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


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

* [Bug c++/13215] [3.3 Regression] bad code generated to call operator new[] when -fcheck-new
  2003-11-28 11:51 [Bug c++/13215] New: bad code generated to call operator new[] when -fcheck-new tom at storagematrix dot com
                   ` (2 preceding siblings ...)
  2003-12-01  2:06 ` [Bug c++/13215] [3.3 Regression] " pinskia at gcc dot gnu dot org
@ 2003-12-21 21:47 ` pinskia at gcc dot gnu dot org
  2003-12-21 21:47 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-21 21:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-21 21:23 -------
I can confirm this with the example without -fcheck-new and it works on them mainline.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|0000-00-00 00:00:00         |2003-12-21 21:23:09
               date|                            |


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


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

* [Bug c++/13215] [3.3 Regression] bad code generated to call operator new[] when -fcheck-new
  2003-11-28 11:51 [Bug c++/13215] New: bad code generated to call operator new[] when -fcheck-new tom at storagematrix dot com
                   ` (3 preceding siblings ...)
  2003-12-21 21:47 ` pinskia at gcc dot gnu dot org
@ 2003-12-21 21:47 ` pinskia at gcc dot gnu dot org
  2003-12-21 21:52 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-21 21:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-21 21:30 -------
The fix went into the mainline between 20030410 and 20030413.

-- 


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


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

* [Bug c++/13215] [3.3 Regression] bad code generated to call operator new[] when -fcheck-new
  2003-11-28 11:51 [Bug c++/13215] New: bad code generated to call operator new[] when -fcheck-new tom at storagematrix dot com
                   ` (4 preceding siblings ...)
  2003-12-21 21:47 ` pinskia at gcc dot gnu dot org
@ 2003-12-21 21:52 ` pinskia at gcc dot gnu dot org
  2003-12-22  5:33 ` mmitchel at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-21 21:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-21 21:40 -------
The patch to fix this is here: <http://gcc.gnu.org/ml/gcc-patches/2003-04/msg00948.html>.
Mark it looks like your patch for 3.3 did not fix all the problems, assigning it to you as your 
patch for the mainline fixes it there.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |mmitchel at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED


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


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

* [Bug c++/13215] [3.3 Regression] bad code generated to call operator new[] when -fcheck-new
  2003-11-28 11:51 [Bug c++/13215] New: bad code generated to call operator new[] when -fcheck-new tom at storagematrix dot com
                   ` (5 preceding siblings ...)
  2003-12-21 21:52 ` pinskia at gcc dot gnu dot org
@ 2003-12-22  5:33 ` mmitchel at gcc dot gnu dot org
  2003-12-22  5:46 ` gdr at integrable-solutions dot net
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2003-12-22  5:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2003-12-22 05:25 -------
It's not practical to backport the mainline changes to GCC 3.3.3.

I don't think that it's worth spending effort to fix this bug for GCC 3.3.3, so
I've removed my name from the assigned field.  However, if I caused this
regression and Gaby thinks it's imperative that this bug be fixed, I will see if
I can fix the problem.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|mmitchel at gcc dot gnu dot |unassigned at gcc dot gnu
                   |org                         |dot org
             Status|ASSIGNED                    |NEW


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


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

* [Bug c++/13215] [3.3 Regression] bad code generated to call operator new[] when -fcheck-new
  2003-11-28 11:51 [Bug c++/13215] New: bad code generated to call operator new[] when -fcheck-new tom at storagematrix dot com
                   ` (6 preceding siblings ...)
  2003-12-22  5:33 ` mmitchel at gcc dot gnu dot org
@ 2003-12-22  5:46 ` gdr at integrable-solutions dot net
  2003-12-22 22:57 ` pinskia at gcc dot gnu dot org
  2005-02-15 22:22 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: gdr at integrable-solutions dot net @ 2003-12-22  5:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2003-12-22 05:30 -------
Subject: Re:  [3.3 Regression] bad code generated to call operator new[] when -fcheck-new

"mmitchel at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| It's not practical to backport the mainline changes to GCC 3.3.3.

So, let's close it as WONTFIX for 3.3.x

Thanks,

-- Gaby


-- 


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


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

* [Bug c++/13215] [3.3 Regression] bad code generated to call operator new[] when -fcheck-new
  2003-11-28 11:51 [Bug c++/13215] New: bad code generated to call operator new[] when -fcheck-new tom at storagematrix dot com
                   ` (7 preceding siblings ...)
  2003-12-22  5:46 ` gdr at integrable-solutions dot net
@ 2003-12-22 22:57 ` pinskia at gcc dot gnu dot org
  2005-02-15 22:22 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-22 22:57 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-22 21:54 -------
Not to be fixed for 3.3.3.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX


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


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

* [Bug c++/13215] [3.3 Regression] bad code generated to call operator new[] when -fcheck-new
  2003-11-28 11:51 [Bug c++/13215] New: bad code generated to call operator new[] when -fcheck-new tom at storagematrix dot com
                   ` (8 preceding siblings ...)
  2003-12-22 22:57 ` pinskia at gcc dot gnu dot org
@ 2005-02-15 22:22 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-15 22:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-15 17:44 -------
*** Bug 19975 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mkunka2 at earthlink dot net


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


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

end of thread, other threads:[~2005-02-15 17:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-28 11:51 [Bug c++/13215] New: bad code generated to call operator new[] when -fcheck-new tom at storagematrix dot com
2003-11-28 13:14 ` [Bug c++/13215] " falk at debian dot org
2003-11-28 17:34 ` [Bug c++/13215] [3.3 only] " pinskia at gcc dot gnu dot org
2003-12-01  2:06 ` [Bug c++/13215] [3.3 Regression] " pinskia at gcc dot gnu dot org
2003-12-21 21:47 ` pinskia at gcc dot gnu dot org
2003-12-21 21:47 ` pinskia at gcc dot gnu dot org
2003-12-21 21:52 ` pinskia at gcc dot gnu dot org
2003-12-22  5:33 ` mmitchel at gcc dot gnu dot org
2003-12-22  5:46 ` gdr at integrable-solutions dot net
2003-12-22 22:57 ` pinskia at gcc dot gnu dot org
2005-02-15 22:22 ` pinskia at gcc dot gnu dot 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).