This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bug or WAD?


Hi,

In our work porting software to Linux (Redhat 5.2, using egcs RPM 1.02-12) we
have come across an interesting disparity between the behaviour of egcs and of
other compilers on other platforms.

We have some code which looks something like this small demonstration program:

--
class cl
{
 public:
  int a;
  void * operator new(unsigned long size)
    { return (void *) 0; };

  cl(int b) { a = b; };
};

int main(void)
{
 class cl *c;

 c = new cl(6);

 printf("does it make it to here?\n");

 return 0;
}
--

Instead of just returning NULL, our code uses a malloc-like call to allocate
storage for the new object.  In one of our testcases this call is forced to
fail returning NULL to simulate an out-of-memory situation.  On most platforms
(including AIX, Solaris, HP-UX, Windows NT, OS/2, etc) this does NOT result in
a catastrophic error.  However on Linux using egcs, it seems the object
constructor is still being called and the program dies with a memory access
violation.

Can anyone tell me if this is "working as designed" or perhaps this is a small
bug?

Please copy my email address if you reply, thanks.
______________________________________________________
Leo Comitale
DB2 Workstation Engine Development, IBM Canada
416-448-4239, Tie Line: 778-4239
comitale@ca.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]