🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.micro.mac
Article #6542

Re: Manx's Mac 1.06H.1 C and assembler bugs

#6542
From: Mark Mendel
Date: Wed, 23 Jul 1986 14:43
27 lines
1312 bytes
>     	register long result;
>     	result = p1->data - p2->data;

(where p1-data is a pointer to a struct)
and 

>     	register long result;
>     	result = (long) p1->data - (long) p2->data;

should not be the same in any C, unless the size of the struct is 1.  This
is because C scales pointer differences to yield the number of things pointed
at between the pointers, not the number of bytes.

	p1->data - p2->data   

is equivalent to

	((long)p1->data - (long)p2->data) / sizeof(*p1->data).

This will be zero if the two structs pointed at overlap.
-- 
-------------------------------------------
Mark G. Mendel, Network Systems Corporation
ihnp4!umn-cs!hyper!mark

All opinions expressed herein, even the most arbitrary, are defended by my 
employer with religious fervor.
Technical Details
Message-ID: <75@hyper.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!caip!meccts!dicome!mmm!umn-cs!hyper!mark
References: <4319@decwrl.DEC.COM>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!caip!meccts!dicome!mmm!umn-cs!hyper!mark
From: mark@hyper.UUCP (Mark Mendel)
Newsgroups: net.micro.mac
Subject: Re: Manx's Mac 1.06H.1 C and assembler bugs
Message-ID: <75@hyper.UUCP>
Date: Wed, 23-Jul-86 10:43:13 EDT
Article-I.D.: hyper.75
Posted: Wed Jul 23 10:43:13 1986
Date-Received: Thu, 24-Jul-86 18:32:43 EDT
References: <4319@decwrl.DEC.COM>
Organization: Network Systems Corp., Mpls., Mn.
Lines: 27