public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Joe Buck <jbuck@synopsys.com>
To: seebs@monolith.solon.com (Peter Seebach)
Cc: egcs@cygnus.com
Subject: Re: linux libio status
Date: Wed, 15 Oct 1997 20:16:00 -0000	[thread overview]
Message-ID: <199710151855.LAA23996@atrus.synopsys.com> (raw)
In-Reply-To: <199710151419.JAA20162@monolith.solon.com>

> It would have been a little easier if C89 had ruled that NULL must
> actually have pointer type, then you could just use it for anything
> that would be taking arguments as (void *), and, if you're feeling
> courageous and not-quite-perfectly-portable, you could just use it
> for all the pointers...

The problem is that C didn't think out this pointer stuff well enough.
The main breakage was to say that (void *) can be assigned to any pointer
type.  But that confuses several types of pointers together into one mishmash.
There are certain distinguished pointer types not directly reflected in
the language:

	-- the null pointer
	-- a "maximally aligned" pointer, as returned by malloc

Such objects can be legally assigned to any pointer type.  Then there is
another beast, the pointer to unknown data object.  We can't say anything
about its alignment.  The problem is that C decided to make all of these
beasts (void *) and permit free casting.

What if there were a new type, aligned_pointer_t.  malloc would return
one of these.  We can safely convert an aligned_pointer to any type of
pointer, so no cast is needed.  Any cast in the reverse direction would
be system-dependent, so a cast is needed.  Similarly, any pointer can
be converted to void *, but neither C nor C++ would allow conversion of
(void *) to another type of pointer without a cast.  Then NULL could
be (aligned_pointer_t)0, and this could work in C or C++.





  reply	other threads:[~1997-10-15 20:16 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-14 23:23 Joe Buck
1997-10-15  0:06 ` Richard Henderson
1997-10-15  0:52 ` Olivier Galibert
1997-10-15  8:25   ` [ECGS] " chip
1997-10-15 11:12   ` Joe Buck
1997-10-15 12:10     ` Olivier Galibert
1997-10-15 16:51       ` [ECGS] " chip
1997-10-15 20:16       ` Joe Buck
1997-10-15 20:16         ` Olivier Galibert
1997-10-16 12:53           ` Pal Engstad
1997-10-15 11:12   ` Peter Seebach
1997-10-15 20:16     ` Joe Buck [this message]
     [not found]   ` <199710151419.JAA20162.cygnus.egcs@monolith.solon.com>
1997-10-15 16:51     ` Jason Merrill
1997-10-15 20:16       ` Peter Seebach
1997-10-15 22:29         ` Jason Merrill
1997-10-16  8:31           ` Peter Seebach
1997-10-16 15:19             ` Jason Merrill
1997-10-16 12:53               ` Peter Seebach
1997-10-16 15:19       ` Paul Koning
     [not found] <199710150623.XAA06491.cygnus.egcs@atrus.synopsys.com>
1997-10-15  2:10 ` Jason Merrill
1997-10-15  9:15   ` Joe Buck
1997-10-15 11:12     ` Per Bothner
1997-10-15 14:33       ` Joe Buck
1997-10-15 16:51         ` Per Bothner
     [not found]         ` <199710152351.QAA02138.cygnus.egcs@cygnus.com>
1997-10-16  1:51           ` Jason Merrill
1997-10-16 12:58             ` Alexandre Oliva
1997-10-16 12:58             ` Joe Buck
1997-10-17 12:53               ` Jason Merrill
1997-10-15 16:51       ` Peter Seebach
1997-10-15 14:33     ` Richard Henderson
1997-10-15 12:10 Greg Galloway
1997-10-15 20:16 ` Joe Buck
1997-10-16 12:58 ` H.J. Lu
1997-10-15 12:10 Greg Galloway
1997-10-16 12:53 ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199710151855.LAA23996@atrus.synopsys.com \
    --to=jbuck@synopsys.com \
    --cc=egcs@cygnus.com \
    --cc=seebs@monolith.solon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).