Bug 24046 - Inheriting from a base class with private scoped operator new/delete pair
Summary: Inheriting from a base class with private scoped operator new/delete pair
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 2.95.3
: P2 normal
Target Milestone: 3.0.x
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2005-09-23 22:01 UTC by Richy Kim
Modified: 2005-09-23 22:05 UTC (History)
1 user (show)

See Also:
Host: Linux 2.4.29
Target: 2.95.3
Build:
Known to work: 3.0.4 3.3.3 3.4.0 4.0.0 4.1.0
Known to fail: 2.95.3
Last reconfirmed:


Attachments
baseopdelete.ii (2.01 KB, application/octet-stream)
2005-09-23 22:02 UTC, Richy Kim
Details
baseopdelete.cpp (189 bytes, application/octet-stream)
2005-09-23 22:04 UTC, Richy Kim
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richy Kim 2005-09-23 22:01:24 UTC
There is a gcc 2.95.3 compiler bug where inheriting from a base class with a
private 'operator delete' (and its matching partner 'operator new') complains
and bails. Privitizing class specific operator new/delete pair is a common idom
to prevent freestore allocation. This is fixed in later version of gcc.


      1 #include <sys/types.h>
      2
      3 class Base
      4 {
      5 public:
      6     Base() {}
      7     ~Base() {}
      8 private:
      9     // Prevent allocation on freestore -- privitize op new/delete
     10     static void* operator new (size_t size);
     11     static void  operator delete(void*);
     12 };
     13
     14 class Derived : public Base
     15 {
     16 public:
     17     Derived() {}
     18     ~Derived() {}
     19 };

% gcc -save-temps -Wall baseopdelete.cpp
baseopdelete.cpp: In method `Derived::~Derived()':
baseopdelete.cpp:11: `static void Base::operator delete(void *)' is private
baseopdelete.cpp:18: within this context
Comment 1 Richy Kim 2005-09-23 22:02:34 UTC
Created attachment 9797 [details]
baseopdelete.ii
Comment 2 Richy Kim 2005-09-23 22:03:58 UTC
% gcc -v
Reading specs from
/opt/third-party/depot/Linux-2.4c2.2-i686/gcc-2.95.3/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/specs
gcc version 2.95.3 20010315 (release)
Comment 3 Richy Kim 2005-09-23 22:04:59 UTC
Created attachment 9798 [details]
baseopdelete.cpp
Comment 4 Andrew Pinski 2005-09-23 22:05:49 UTC
Yes 2.95.3 is 4 years old and have not been maintined for about 4 years now.
This was fixed in 3.0 which also stoped being maintained for 3 years.