Article View: comp.std.c
Article #4075Re: Converting between pointer types
From: Tanmoy Bhattacharya
Date: Wed, 20 Sep 1995 23:57
Date: Wed, 20 Sep 1995 23:57
50 lines
2603 bytes
2603 bytes
In article <43q1ko$q5s@Radon.Stanford.EDU>, becker@Xenon.Stanford.EDU
(Denizen of the Deep) writes:
<snip>
|> So if I write a program which invokes undefined behavior all over
|> the place, but I can find one conforming implementation which will
|> accept it, then I can say that my program is a conforming C
|> program?
Yes. That is why a conforming C program is a practically meaningless term.
|>
|> This gives new meaning to the whole "void main(void)" debate. After
|> all, I know plenty of implementations which will accept that (and
|> some of them are even conforming :-).
Theorem: As long as there exists a conforming C implementation on a powerful
enough OS, no program is ever a non-conforming C program.
Proof: Let us say that we are testing X for conformance.
Create a file called X which contains the above program.
Write the following shell script (or its equivalent in that OS)
#!/bin/sh
if ! $(COMPILE) X ; then
if ! diff X $1 ; then
cp `which true` a.out
fi
fi
This shell script (along with proper documentation and run time
support) is trivially a conforming implementation with the proper
definition of COMPILE: and it `compiles' X to a program that runs
without error.
|>
|> What exactly does it mean to say that an implementation "accepts"
|> a program? That it successfully compiles it (with or without
|> non-fatal warnings)?
None of these is precisely defined in the standard. However, as I said: it
does not matter. I could trivially modify the above to make any given X
compile without diagnostic!
Cheers
Tanmoy
--
tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87544-0285,USA H:#3,802,9 St,NM87545
Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
<http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
Technical Details
Message-ID:
<43q9om$4bv@newshost.lanl.gov>Path:
arc1-ca.pugleaf.net!qcd.lanl.gov!tanmoyReferences:
<43n718$ns@Radon.Stanford.EDU> <DF6uIu.D8t@stdc.demon.co.uk> <43q1ko$q5s@Radon.Stanford.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!qcd.lanl.gov!tanmoy From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya) Newsgroups: comp.std.c Subject: Re: Converting between pointer types Date: 20 Sep 1995 23:57:10 GMT Organization: Los Alamos National Laboratory Distribution: world Message-ID: <43q9om$4bv@newshost.lanl.gov> References: <43n718$ns@Radon.Stanford.EDU> <DF6uIu.D8t@stdc.demon.co.uk> <43q1ko$q5s@Radon.Stanford.EDU> NNTP-Posting-Host: qcd.lanl.gov