From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: from minnie.tuhs.org (minnie.tuhs.org [IPv6:2600:3c01:e000:146::1]) by inbox.vuxu.org (Postfix) with ESMTP id 719D92587F for ; Fri, 20 Sep 2024 17:24:42 +0200 (CEST) Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id 4489943713; Sat, 21 Sep 2024 01:24:38 +1000 (AEST) Received: from mail-vs1-xe2a.google.com (mail-vs1-xe2a.google.com [IPv6:2607:f8b0:4864:20::e2a]) by minnie.tuhs.org (Postfix) with ESMTPS id C48A14370C for ; Sat, 21 Sep 2024 01:24:32 +1000 (AEST) Received: by mail-vs1-xe2a.google.com with SMTP id ada2fe7eead31-49bc12c0041so701018137.0 for ; Fri, 20 Sep 2024 08:24:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dartmouth.edu; s=google1; t=1726845872; x=1727450672; darn=tuhs.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=M4yBsSw8F9o9c1wgGbHqZB1jZlSgYo78ihbL75L0whA=; b=DdxUNk1CkExtyi5hhO5CflvcevTforV9O0+vvgZHzAu2g0jYmBSl0wrJ0KIs5wRK0g koJIBF76PzPb0KbYOrc9garwDGEJPe9DmFuUxdcWHefFcIQLQAXLnfzqh8Y8i99wKIZL gBsez8U0e9GEK+TDhIcG2Pl/SsvUxNQqjGii5aM2kYjkXMoctBWGItxDA+n0hOLI6OPo RnCwoZtRo+elZaTjpyUWODcSsO7wVwTejI5ocApexA/mPLsjTqhGNep8gyf9/2XkVagV HXwWF887G6aGTnoTzet/LTcfocJAVvG3avk1T8JCM8/wMMzAWoc23cvPQPjeDvX+znyu tagg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726845872; x=1727450672; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=M4yBsSw8F9o9c1wgGbHqZB1jZlSgYo78ihbL75L0whA=; b=oB0BfGfCYvtmbMvbIk18DkseWyQRBAAbtZ+/EJGUvgnXPvsEfo+gTPF9L97EKGhLkj 2SBdzmONzq2XL6BFKQgr/0ik3gaS838Upz+cdJ9HgIa+FAZSBF/woauovVkvRuOW0gPi wUi1sLmDYSHyG5gcHxWVj5PeVrlp4bqk9Whnw7H3m2yhX5XCW2IcTEjAgDnAPSRid2qO 5Gqz18ZpHCleL35WAI9ELj+6Xy4lZqsLwvq/lzQhZtPQvljENpZw7e3mRjtu3pe2jsXW jITogMWkJL1geQ23C5z/Bh5D3JzHAGpu2Yhy/Pl0YA/46q1yd8UrkD/w+9u3pS4kgsp7 N1AQ== X-Gm-Message-State: AOJu0YxkUiA4ThBrAaF/iZmYhNaTnyBepvquDzd/xYfNlp5+XlAsQKGe ISm4zoTpfu6QcVZ4Q2UfoNqrhLJYdlbzCSRMr2bqZDUBatIr55kp2n0jfY4QfxSKRc+LQ04qK9K r6Iox0gMcjjDAL1jHF1XuVQh2dsiAX93Z8FSkpUFgNJUUZ9xUisg= X-Google-Smtp-Source: AGHT+IFd2HnC3Au0b6CP1svva403yTMGdtQ9LJsXThB6lnrDcWtQqG290qV9BpYbifUXZulycYmojumvQTv5R6TJdb0= X-Received: by 2002:a05:6102:3051:b0:498:cdb0:1d03 with SMTP id ada2fe7eead31-49fc9639e88mr2209769137.23.1726845871887; Fri, 20 Sep 2024 08:24:31 -0700 (PDT) MIME-Version: 1.0 From: Douglas McIlroy Date: Fri, 20 Sep 2024 11:24:16 -0400 Message-ID: To: TUHS main list Content-Type: multipart/alternative; boundary="000000000000c6b31506228ea278" Message-ID-Hash: Q264AHMLLONBXJ3YSXOSZ2BE2R6F7VPT X-Message-ID-Hash: Q264AHMLLONBXJ3YSXOSZ2BE2R6F7VPT X-MailFrom: douglas.mcilroy@dartmouth.edu X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-tuhs.tuhs.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [TUHS] Re: Maximum Array Sizes in 16 bit C List-Id: The Unix Heritage Society mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --000000000000c6b31506228ea278 Content-Type: text/plain; charset="UTF-8" Apropos of the virtue of negative subscripts. > by pointing into the middle of another data structure you've created a data aliasing situation Not if all references are relative to the offset pointer. The following example is silly, but I recently used exactly this trick to simplify calculations on a first-quadrant (x,y) grid by supplying "out-of-bounds" zeroes at (x,-2), (x,-1) and (-1,y). It was much cleaner to access the zeroes like ordinary elements than to provide special code to handle the boundary conditions. /* Fill an N-element array with Fibonacci numbers, f(i), where 0<=i
Apropos of the virtue of negative su= bscripts.

> by pointing into the middle of anot= her data structure you've created a data aliasing situation
<= br>
Not if all references are relative to the offset pointer. The= following example is silly,=C2=A0 but I recently used exactly this trick t= o simplify calculations on a first-quadrant (x,y) grid by supplying "o= ut-of-bounds" zeroes at (x,-2), (x,-1) and (-1,y). It was much cleaner= to access the zeroes like ordinary elements than to provide special code t= o handle the boundary conditions.

/* Fill an N-ele= ment array with Fibonacci numbers, f(i), where 0<=3Di<N.=C2=A0
<= div>=C2=A0 =C2=A0The recursion accesses a zero "out of bounds" at= i=3D-1 */

const int N =3D 100;

int base[N+1];
#define fib(i) base[(i)+1]

void fill() {
=C2=A0 =C2=A0 int i;
=C2=A0 =C2= =A0 fib(0) =3D 1;
=C2=A0 =C2=A0 for(i=3D1; i<N; i++)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 fib(i) =3D fib(i-2) + fib(i-1);
}

Doug


--000000000000c6b31506228ea278--