🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #1122

Re: Pointers as 3-tuples (Re: JLG's flogging of horses (was Re: Relationship between C and C++))

#1122
From: Peter da Silva
Date: Sat, 07 Apr 1990 18:02
28 lines
1368 bytes
In article <14309@lambda.UUCP> jlg@lambda.UUCP (Jim Giles) misses the point
and goes off on a tangent:
> Well, as has already been pointed out, the pA=A assignment is actually
> _illegal_ in C.

It's not illegal in C. It's an implicit type-cast on assignment.

To avoid a warning you must now use:

	pA = (t *)A;

> As for "known at compile time" - well, N and M aren't if they were
> passed as parameters.

Sure, because A was passed as a 3-tuple. N and M aren't known explicitly
unless declared, but N*M is known. And that's all you need to bound-check
this baby.

The point I'm making isn't that array indexing is or is not better than
pointers, but that for the purpose at hand neither array indexing or pointers
is better or worse at bounds checking.

Just think of *A as a shorthand for A[0].
-- 
 _--_|\  `-_-' Peter da Silva. +1 713 274 5180. <peter@ficc.uu.net>.
/      \  'U`
\_.--._/
      v
Technical Details
Message-ID: <ZZR2:M4xds13@ficc.uu.net>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!ficc!peter
References: <5.Q2H42xds13@ficc.uu.net> <14309@lambda.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!ficc!peter
From: peter@ficc.uu.net (Peter da Silva)
Newsgroups: comp.lang.misc
Subject: Re: Pointers as 3-tuples (Re: JLG's flogging of horses (was Re: Relationship between C and C++))
Message-ID: <ZZR2:M4xds13@ficc.uu.net>
Date: 7 Apr 90 18:02:29 GMT
References: <5.Q2H42xds13@ficc.uu.net> <14309@lambda.UUCP>
Reply-To: peter@ficc.uu.net (Peter da Silva)
Organization: Xenix Support, FICC
Lines: 23