🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #330

Re: AVL tree insertion - programming exercise

#330
From: Keith Thompson
Date: Tue, 13 Oct 2026 12:09
35 lines
2829 bytes
David Brown <david.brown@hesbynett.no> writes:
> On 13/10/2026 13:29, Keith Thompson wrote:
[...]
>> Typically yes, but the standard says nearly nothing about how
>> pointers are represented.  If your assume a 64-bit aligned pointer
>> has zeros in the 3 LSBs, it's at least potentionally non-portable.
>> (The systems I've used that broke that assumption are most likely
>> no longer in use.)
>
> Would it be safe to assume that the 3 LSB's have a consistent value?
> (I am not suggesting it's a good idea.)

No.

I didn't go into detail because I've described it here a number of
times, but it's been a while.

The systems in question were Cray vector systems, T90 and others.  A
machine address pointed to a 64-bit word, but CHAR_BIT==8 because it
had a Unix-like OS (Unicos).  A pointer to a 64-bit word could have
any arbitrary values in its 3 LSBs.  Byte pointers were synthesized
by the compiler, with the 3-bit byte offset within a word stored
in the otherwise unused *upper* 3 bits of the 64-bit pointer.

C string operations were remarkably slow -- but of course these
systems were heavily optimized for floating-point.

I actually fixed some C code that computed the difference between
two pointers by converting them and doing an integer subtraction.
A direct pointer subtraction was simpler (at least in source code)
and had the virtue of being correct.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Technical Details
Message-ID: <11al71p$fqtl$2@kst.eternal-september.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!kst.eternal-september.org!.POSTED!not-for-mail
References: <86ece2kppv.fsf@linuxsc.com> <11akqm4$c6h9$1@dont-email.me> <11akuf1$bq6c$1@dont-email.me> <11al4mu$fqtl$1@kst.eternal-september.org> <11al6i1$gct5$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!kst.eternal-september.org!.POSTED!not-for-mail
From: Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: AVL tree insertion - programming exercise
Date: Tue, 13 Oct 2026 05:09:28 -0700
Organization: None to speak of
Lines: 35
Message-ID: <11al71p$fqtl$2@kst.eternal-september.org>
References: <86ece2kppv.fsf@linuxsc.com> <11akqm4$c6h9$1@dont-email.me>
	<11akuf1$bq6c$1@dont-email.me>
	<11al4mu$fqtl$1@kst.eternal-september.org>
	<11al6i1$gct5$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Tue, 13 Oct 2026 12:09:30 +0000 (UTC)
Injection-Info: kst.eternal-september.org;
	logging-data="519093"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/9jEKmHk4qWRs4jW6hy7Bf"; posting-host="11ac7c4b547d7ca6b42084bf5cca4a8e"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:i7oQ6WJizVeo6IIzd9GI6m5mnyk= sha256:VWarPWF9M/uku27Hmd0ZLZZ3Z7DDue8VjQKyOgVPIEA=
	sha1:OioNcA8Fdz4Sg/WiM181Pl+BuDE= sha256:9FmNsplxYzoH9ElQgEj/1W33Ifcq4la0SnogLzgaAjU=