🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3901

Re: Memory Problem with C/C++

#3901
From: Shaun Flisakowski
Date: Sat, 02 Sep 1995 08:36
21 lines
1119 bytes
In article <1995Sep1.191718@airvax.air.ups.com>,
 <air1jxy@airvax.air.ups.com> wrote:
>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.
>
[snip]
>{
>  char* c = (char*) malloc(1024);
>  double *db = (double*) (c + 4);
>}

    The HP 715 I use, (and the Sun Sparc 10 I have access to) both 
    require double-word alignment for double types, which for both
    of these machines sizeof(double) is 8.  Notice the problem
    will not occur for (c+0), (c+8), (c+16), etc.

    This has nothing to do with the compiler, but is rather a 
    feature of the architecture you are using.

    Shaun
Technical Details
Message-ID: <429522$6r4@spool.cs.wisc.edu>
Path: arc1-ca.pugleaf.net!fontina.cs.wisc.edu!flisakow
References: <1995Sep1.191718@airvax.air.ups.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!fontina.cs.wisc.edu!flisakow
From: flisakow@fontina.cs.wisc.edu (Shaun Flisakowski)
Newsgroups: comp.std.c
Subject: Re: Memory Problem with C/C++
Date: 2 Sep 1995 08:36:18 GMT
Organization: U of Wisconsin CS Dept
Message-ID: <429522$6r4@spool.cs.wisc.edu>
References: <1995Sep1.191718@airvax.air.ups.com>
NNTP-Posting-Host: fontina.cs.wisc.edu