size of a sizeof(pointer)

M

Malcolm

Michael Wojcik said:
1. Most C implementations do not check pointer validity. True.
2. Some, however, do; the three I named for the AS/400 are
examples. True.
3. I feel that (2) is a significant exception to (1). Fair enough.
4. You do not.
I feel it is a special case, because the C does not compile to machine code.
5. The origin and preferred usage of the phrase "the exception that
proves the rule" is disputed.
The origin may be the legal principle, but etymology isn't meaning. The
proverb is used in two ways, ignorantly to mean that "if a rule has an
exception then that proves the rule must be valid" and correctly "by looking
at seeming exceptions we tell if the rule is valid or not".
6. However, some people - including myself and some other c.l.c
readers - feel that when that phrase is used to mean "an
exception to a general rule demonstrates the validity of that
rule in other cases", it's somewhat lacking in rhetorical power.
Other people, of course, may feel differently.
It's the difference between the rule "all mammals are viviparous" and "no
mammals are eusocial". Both have exceptions. When we look at oviparous
mammals, the monotremes, we see that they belong to a tiny group that split
off very early and is only included in "mammals" by definiton. We can use
the rule to predict that we won't find an oviparous cat. However when we
look at the eusocial mammals - naked mole rats and, partially, wolves - we
see that there does not appear to be anything special about them. There
doesn't seem to be anything about being a mammal that precludes eusociality,
and if we found a new species of cat we can't be sure it won't be eusocial.
 
D

Dave Thompson

On 15 Feb 2004 18:55:20 GMT said:
Given that we have the word "translator", however, I personally
would tend to use that word for a system in which the "produce
something useful" step requires outside assistance, such as a
C++-to-C step that not only does not come with a C compiler, but
is provided for a computer for which no C compiler is even available.
It is probably also worth pointing out that there are a number% of
compilers that have produced C as their "assembly code", but in
all cases of which I am aware, that C code was not portable at all
-- you had to tell the XYZ-to-C step [implementation specifics]
[%footnote: when I say "a number" I do mean "more than one". While
cfront is perhaps the best-known example, I believe Xerox PARC had
C back-ends for some of their compilers, for the language that was
a followon to Mesa -- I have forgotten its name -- and for Modula-3,
for instance.]

"most" Eiffels. At least one Ada which I believe is still sold. f2c,
and I think p2c. I believe all Objective C's, and Comeau C++.

And of course any number (well, not *any* <G>) of tools which produce
C code from some other kind of program decription or specification,
like UML or flowcharts or logic diagrams etc. etc., although we (IME)
usually call those generators rather than translators or compilers.

- David.Thompson1 at worldnet.att.net
 
D

Dave Thompson

You can't implement the whole standard library,
if sizeof(int) is one.

putchar(EOF) has to be able to return EOF
converted to an unsigned char value,
converted back to a nonnegative int.

http://groups.google.com/groups?selm=Pine.LNX.4.58-035.0401180136310.21889@unix41.andrew.cmu.edu

No, it needs to return any unsigned char value (which need not and
normally does not include EOF) *or* EOF as a signed int. It apparently
was intended, and certainly is traditional, that these are distinct,
i.e. (int)UCHAR_MAX != EOF, but the standard doesn't require it, and
if not, programs using stdio have to be a lot more careful.

AFAWK implementations on which sizeof(int)==1 are all freestanding
ones on platforms where stdio isn't useful, or feasible, or both, so
the issue doesn't arise in practice. And since so few programs (and
programmers) are careful in this way, even if such a hosted (full)
implementation were created it wouldn't be popular unless it had some
huge other benefit(s).

- David.Thompson1 at worldnet.att.net
 
G

Greg Comeau

On 15 Feb 2004 18:55:20 GMT said:
Given that we have the word "translator", however, I personally
would tend to use that word for a system in which the "produce
something useful" step requires outside assistance, such as a
C++-to-C step that not only does not come with a C compiler, but
is provided for a computer for which no C compiler is even available.
It is probably also worth pointing out that there are a number% of
compilers that have produced C as their "assembly code", but in
all cases of which I am aware, that C code was not portable at all
-- you had to tell the XYZ-to-C step [implementation specifics]
[%footnote: when I say "a number" I do mean "more than one". While
cfront is perhaps the best-known example, I believe Xerox PARC had
C back-ends for some of their compilers, for the language that was
a followon to Mesa -- I have forgotten its name -- and for Modula-3,
for instance.]

"most" Eiffels. At least one Ada which I believe is still sold. f2c,
and I think p2c. I believe all Objective C's, and Comeau C++.

And of course any number (well, not *any* <G>) of tools which produce
C code from some other kind of program decription or specification,
like UML or flowcharts or logic diagrams etc. etc., although we (IME)
usually call those generators rather than translators or compilers.

Indeed there are many. Another is CCsh, a Bourne Shell compiler
that Comeau also sells. Actually, the C code it produces is
extraordinarily portable, however, it depends, heavily, upon a
platform specific library to go along with it, so in the end there
is no escaping it :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top