Article View: comp.std.c
Article #3897Memory Problem with C/C++
From: air1jxy
Date: Fri, 01 Sep 1995 23:17
Date: Fri, 01 Sep 1995 23:17
22 lines
939 bytes
939 bytes
To All You Compiler/Language Expert Out There:
We encountered a memory problem when trying to use memory pool for a
class with double data member. The pool manager can be as simple as
the one on Stroustrup's book (page 473). The following piece of code
demostrate the problem. Compile and run it. It may crash on you.
It crashed on us on a HP735 with HPUX9.01 and CFront 3.0.
Jin Yang
United Parcel Service Airlines
air1jxy@orhp735a.air.ups.com
//--------------------------------------------------------------------
#include <stdlib.h>
int main()
{
char* c = (char*) malloc(1024);
double *db = (double*) (c + 4);
*db = 10.0;
}
Technical Details
Message-ID:
<1995Sep1.191718@airvax.air.ups.com>Path:
arc1-ca.pugleaf.net!airvax.air.ups.com!air1jxyShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!airvax.air.ups.com!air1jxy From: air1jxy@airvax.air.ups.com Newsgroups: comp.std.c Subject: Memory Problem with C/C++ Date: 1 Sep 95 19:17:18 EDT Organization: United Parcel Service Message-ID: <1995Sep1.191718@airvax.air.ups.com> NNTP-Posting-Host: 153.2.131.10