Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #105812
| From | BartC <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Return statement: anything goes? |
| Date | 2017-03-11 19:34 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <oa1jbf$uis$1@dont-email.me> (permalink) |
| References | (5 earlier) <87d1dnyi73.fsf@bsb.me.uk> <oa18ji$l75$1@dont-email.me> <877f3vyach.fsf@bsb.me.uk> <oa1dle$6qa$1@dont-email.me> <b592c7be-be2e-49ec-8a43-668d64dcd412@googlegroups.com> |
On 11/03/2017 18:59, jameskuyper@verizon.net wrote: > On Saturday, March 11, 2017 at 12:57:52 PM UTC-5, Bart wrote: >> On 11/03/2017 17:47, Ben Bacarisse wrote: >>> BartC <bc@freeuk.com> writes: >>> >>>> On 11/03/2017 14:57, Ben Bacarisse wrote: >> >>>>> But this raises the question of why you would implement C at all. >>>> >>>> Just for fun. >>> >>> Ah, I see. You can do pretty much what you like then. >> >> Well, it also has to work. That means compiling and running other >> people's code /without changes/. > > So, what other code are you willing to require your compiler to accept without changes? You've got to limit it in some fashion. If you include all conforming programs to the list, you've created an impossible requirement. Code that is entirely correct, containing no syntax errors, constraint violations or undefined behavior may still contain code that behaves differently when compiled by different compilers, due to things that the C standard leaves unspecified. As far as the author of deliberately non-portable code is concerned, if it has different behavior when translated by some other implementations than it would have when translated by the target implementation, that different behavior is incorrect behavior. Therefore, the only way your compiler could produce the correct behavior is by knowing how the intended target implementation would handle such code - which is something your compiler could not figure out from the code itself. > > Do you want to restrict the code that your compiler is required to translate correctly to include all strictly conforming programs? If so, that comes close to requiring full conformance with the C standard. That would certainly be the case for the particular issues you raised in this thread. > > "strictly conforming code" is pretty restrictive - there's very few real-world programs that qualify. Do you want your compiler to correctly translate a wider variety of programs? If so, you need to decide how wide a variety you want it to handle. My aim would be to try compile anything that works with my range of Windows C compilers (Pelles C, lccwin, DMC, Tiny C, gcc and, possibly, MSVC, although that one is harder to invoke). Such a project will also have passed these obstacles: * A configuration step (that might depend on importing most of Linux) * Having build instructions hidden inside a makefile * Not being dependent on a specific set of compile options * Not requiring features, extensions or macro defines from a specific compiler * Not needing a library only available with a specific implementation. Compiling Linux projects would be more difficult. (As I would rely on Linux header files full of stuff I can't deal with. I can't compile gcc headers because they are full of gcc-specific features, and I can't easily prise Linux headers and gcc headers apart.) Apart from that, there will be practical problems (I won't have the range of headers that normally come with a compiler, such as windows.h; I would need to piggy-back onto an existing compiler's files; it gets messy.) Also I won't initially implement VLAs (although I'm not sure if MSVC has them either; my 2008 version doesn't seem to). Actually compiling user-code will be the least of the problems, and I am prepared to comment out checks to make the code pass. (Code that I write or generate myself, I don't anticipate problems with. I already write it to work on any compiler and on either Windows or Linux.) -- bartc
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-10 19:13 +0000
Re: Return statement: anything goes? John Bode <jfbode1029@gmail.com> - 2017-03-10 11:59 -0800
Re: Return statement: anything goes? Keith Thompson <kst-u@mib.org> - 2017-03-10 12:34 -0800
Re: Return statement: anything goes? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-10 20:17 +0000
Re: Return statement: anything goes? bart4858@gmail.com - 2017-03-10 13:17 -0800
Re: Return statement: anything goes? Ian Collins <ian-news@hotmail.com> - 2017-03-11 10:30 +1300
Re: Return statement: anything goes? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-11 01:25 +0000
Re: Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-11 12:11 +0000
Re: Return statement: anything goes? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-11 14:57 +0000
Re: Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-11 16:31 +0000
Re: Return statement: anything goes? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-11 17:47 +0000
Re: Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-11 17:57 +0000
Re: Return statement: anything goes? jameskuyper@verizon.net - 2017-03-11 10:59 -0800
Re: Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-11 19:34 +0000
Re: Return statement: anything goes? jameskuyper@verizon.net - 2017-03-11 11:59 -0800
Re: Return statement: anything goes? supercat@casperkitty.com - 2017-03-11 12:26 -0800
Re: Return statement: anything goes? supercat@casperkitty.com - 2017-03-11 12:22 -0800
Re: Return statement: anything goes? jameskuyper@verizon.net - 2017-03-11 12:42 -0800
Re: Return statement: anything goes? supercat@casperkitty.com - 2017-03-11 13:01 -0800
Re: Return statement: anything goes? Gordon Burditt <gordon@hammy.burditt.org> - 2017-03-13 16:25 -0500
Re: Return statement: anything goes? Gareth Owen <gwowen@gmail.com> - 2017-03-11 16:43 +0000
Re: Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-11 18:13 +0000
Re: Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-11 18:27 +0000
Re: Return statement: anything goes? gordonb.rlpr3@burditt.org (Gordon Burditt) - 2017-03-13 16:18 -0500
Re: Return statement: anything goes? supercat@casperkitty.com - 2017-03-11 12:44 -0800
Re: Return statement: anything goes? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-03-11 07:43 -0800
Re: Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-11 18:34 +0000
Re: Return statement: anything goes? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-03-11 10:43 -0800
Re: Return statement: anything goes? Keith Thompson <kst-u@mib.org> - 2017-03-10 12:27 -0800
Re: Return statement: anything goes? Noob <root@127.0.0.1> - 2017-03-10 22:06 +0100
Re: Return statement: anything goes? bart4858@gmail.com - 2017-03-10 13:26 -0800
Re: Return statement: anything goes? antispam@math.uni.wroc.pl - 2017-03-12 05:29 +0000
Re: Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-12 10:52 +0000
Re: Return statement: anything goes? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-12 12:19 +0000
Re: Return statement: anything goes? BartC <bc@freeuk.com> - 2017-03-12 12:51 +0000
csiph-web