comp.lang.ada
 help / color / mirror / Atom feed
From: "Warren W. Gay VE3WWG" <ve3wwg@home.com>
Subject: Re: type Foo_ptr in new void*;
Date: Tue, 31 Jul 2001 02:14:28 GMT
Date: 2001-07-31T02:14:28+00:00	[thread overview]
Message-ID: <3B661483.EE6658AB@home.com> (raw)
In-Reply-To: 3B64D0B0.33323E3B@worldnet.att.net

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



  reply	other threads:[~2001-07-31  2:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-29  4:31 type Foo_ptr in new void*; Tomasz Wegrzanowski
2001-07-29  5:56 ` tmoran
2001-07-29  8:57   ` Tomasz Wegrzanowski
2001-07-29 12:26     ` Marc A. Criley
2001-07-30  1:05       ` Tomasz Wegrzanowski
2001-07-30  1:20         ` tmoran
2001-07-30  2:09         ` James Rogers
2001-07-30  2:36           ` Warren W. Gay VE3WWG
2001-07-30  3:10             ` James Rogers
2001-07-31  2:14               ` Warren W. Gay VE3WWG [this message]
2001-07-31  1:21           ` Tomasz Wegrzanowski
2001-07-31  3:06             ` James Rogers
2001-07-31  5:02               ` Warren W. Gay VE3WWG
2001-07-31  7:22               ` Florian Weimer
2001-07-31  4:56           ` Darren New
2001-08-04  6:05             ` David Thompson
2001-08-05  2:27               ` Warren W. Gay VE3WWG
2001-07-29 13:40     ` Dale Stanbrough
2001-07-29 14:12 ` Florian Weimer
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox