From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4deb6c62a5e19f2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-30 19:14:28 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!paloalto-snf1.gtei.net!news.gtei.net!enews.sgi.com!newshub2.rdc1.sfba.home.com!news.home.com!news1.rdc2.on.home.com.POSTED!not-for-mail Message-ID: <3B661483.EE6658AB@home.com> From: "Warren W. Gay VE3WWG" X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: type Foo_ptr in new void*; References: <9k03jc$2me$2@news.tpi.pl> <9k0j60$n4t$1@news.tpi.pl> <3B63F48A.2E2642C6@earthlink.net> <9k2btj$5hj$1@news.tpi.pl> <3B64C26F.C195B4E0@worldnet.att.net> <3B64C812.8CA53003@home.com> <3B64D0B0.33323E3B@worldnet.att.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Tue, 31 Jul 2001 02:14:28 GMT NNTP-Posting-Host: 24.141.193.224 X-Complaints-To: abuse@home.net X-Trace: news1.rdc2.on.home.com 996545668 24.141.193.224 (Mon, 30 Jul 2001 19:14:28 PDT) NNTP-Posting-Date: Mon, 30 Jul 2001 19:14:28 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:10803 Date: 2001-07-31T02:14:28+00:00 List-Id: James Rogers wrote: > "Warren W. Gay VE3WWG" wrote: > > > > I don't think your "unspecified behavior" assertion is truly fair here. > > I believe that when you reach a point in the C/C++ compile where > > pointer arithmetic is required on the "undefined type", you will get > > a compile error. The compiler will not generate code that does > > "undefined behaviour" here. If there is any further doubt about it, > > I am sure this can be tested with a short example program. > > Your assertion may be true for C++ compilers, but it was not true > for C compilers in the early 1990s. I've been using C for a long time, and I've used a number of C compilers. In that experience, I've never seen it compile pointer arithmetic on non-defined pointer types (you'll get a compiler error at the point where the arithmetic is required). If you can site a specific example, I might believe it. Even then, I'd have to say that it was unusual and attributable to a bad C compiler. > > Ada does permit you to define an incomplete type as well, but the > > condition is that it must be defined eventually. I agree that enforcing > > its later definition, is a good thing. > > Let's be a little more precise here. Ada does not allow you to define > incomplete types. You know what I meant. However, for everyone else, here is precisely what I was trying to describe: package X is type My_Type; -- Not fully defined.... type My_Type_Ptr is access all My_Type; -- Here My_Type is still _not_ defined yet... type My_Type is record Name : String(1..8); Next : My_Type_Ptr; -- Ptr to next end record; end X; Between the statement "type My_Type;" and the full declaration at the bottom, like C, you can have a forward referencing type, where it is not fully defined. Note that in this case, there is no other way to define the My_Type_Ptr member Next in My_Type. This is why it is permitted. -- Warren W. Gay VE3WWG http://members.home.net/ve3wwg