public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@transmeta.com>
To: Morten Welinder <terra@diku.dk>
Cc: <gcc@gcc.gnu.org>
Subject: Re: Big-endian Gcc on Intel IA32
Date: Tue, 18 Dec 2001 14:48:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.33.0112181411370.3275-100000@penguin.transmeta.com> (raw)
In-Reply-To: <20011218192658.16865.qmail@tyr.diku.dk>


On 18 Dec 2001, Morten Welinder wrote:
> Now I realize that you are not about to rewrite the kernel in C++
> (unless you have sampled a bit too much Glogg recently, :-)  What
> I am saying is that you could probably make minor changes to the
> current source code such that...
>
> 1. Its C interpretation does not change.
> 2. Its C++ interpretation would have a user_data* type and do the
>    check you ask for.

Well, there is actually a project (the "stanford checker") which goes even
further than this, and does an instrumented gcc back-end, where you can
add a lot of almost arbitrary rules on what constitutes tainting.

The problem with it is that it's not automatic, and it doesn't give the
kind of "immediate feedback" as a direct compiler warning or error does.

Your suggestion of using C++ as a separate checker is not really much more
than a very cut-down version of the (quite interesting) standford project.
It might make it slightly easier for people to check, but it's not quite
there..

> I seem to remember that once upon a time you said that you wanted
> type int when you deal with ints (as opposed to having some typedef
> name like off_t).  If that is still true, I guess you will not like
> this kind of approach.

I don't like abstraction for abstractions sake - a lot of people seem to
want to abstract things just because they _can_, not because it makes any
real sense. For example, POSIX wanted to abstract the "length of a socket
name", and created "socklen_t", which simply _has_ to be the same as "int"
if you are going to be compatible with historical uses (and has to support
all the same operations etc, so it's not a opaque type in any case). That
is a useless abstraction - you're not actually adding information, you're
only adding chaos.

However, in other cases it can be quite useful to specify a "immutable"
type. There are many cases where you have basically integer types, but
they are integers that have emplicit meaning, and doing arithmetic on them
is a nonsensical operation.

Linux actually ends up embedding some of these as unique structures, just
because that's the only way to strengthen the C type set. It does
sometimes impact code quality (gcc seems to be better at returning
integers than returning integers wrapped in a structure etc), but not by
much, and the abstraction you get in these cases is definitely worth it.

However, creating a new structure type for each thing is actually quite a
lot of effort, and gets tedious. So just a set of "taint bits" would be
syntactically easier.

(To the person suggesting how to do it in C++ - you _can_ get a subset of
this in C by the above "embed in a structure" trick).

		Linus

  parent reply	other threads:[~2001-12-18 22:30 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-18 11:41 Morten Welinder
2001-12-18 11:42 ` Phil Edwards
2001-12-18 14:48 ` Linus Torvalds [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-12-23  7:26 dewar
2001-12-23  7:06 dewar
2001-12-23  7:08 ` Florian Weimer
2001-12-20  5:36 Etienne Lorrain
2001-12-19 11:47 Bernard Dautrevaux
2001-12-19 13:09 ` Linus Torvalds
2001-12-18  3:49 dewar
2001-12-23  6:59 ` Florian Weimer
2001-12-17 18:39 dewar
2001-12-17 18:59 ` Per Bothner
2001-12-17 13:14 dewar
2001-12-17 13:42 ` guerby
2001-12-17 13:43 ` Linus Torvalds
2001-12-17 14:22   ` guerby
2001-12-17 14:52     ` Linus Torvalds
2001-12-17 15:01   ` Richard Henderson
2001-12-17 15:12     ` Linus Torvalds
2001-12-17 15:54       ` Richard Henderson
2001-12-17 17:43         ` Linus Torvalds
2001-12-17 18:12           ` Richard Henderson
2001-12-18 11:55       ` Jason Riedy
2001-12-17 16:43   ` Ross Smith
2001-12-18  1:28 ` Florian Weimer
2001-12-17 12:08 dewar
2001-12-17 13:10 ` Linus Torvalds
2001-12-17 14:00   ` Alan Lehotsky
2001-12-17 12:00 Ghanta, Bose

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=Pine.LNX.4.33.0112181411370.3275-100000@penguin.transmeta.com \
    --to=torvalds@transmeta.com \
    --cc=gcc@gcc.gnu.org \
    --cc=terra@diku.dk \
    /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).