Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #155015
| From | Tim Rentsch <tr.17687@z991.linuxsc.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Two different Results between C and C++ |
| Date | 2020-09-15 05:01 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <86lfhb1c77.fsf@linuxsc.com> (permalink) |
| References | (11 earlier) <7abdc18a-78b6-4fb5-a7f7-82e6b220b389o@googlegroups.com> <86tuw85ocl.fsf@linuxsc.com> <83c9cb00-6c52-4837-95a2-6cfe31eb5d88o@googlegroups.com> <86pn6q2qqy.fsf@linuxsc.com> <a5e96b18-4ae4-4d9a-a285-74486cbb38e2o@googlegroups.com> |
Tiib <ootiib@hot.ee> writes: > On Sunday, 13 September 2020 08:24:59 UTC+3, Tim Rentsch wrote: >> Tiib <ootiib@hot.ee> writes: [..pruning..] >>> You seem -------to ignore fact that very close to all "real >>> world" programs are defective and so the equivalence isn't (and >>> can't be) mathematical. >> >> Of course it can be. There are lots of ways to transform a >> program into a different program that has identical semantics, >> whether or not the original program has defects. The transformed >> program will then have exactly the same defects as the original. >> Example: this declaration >> >> int x = 1; >> >> has exactly the same semantics as the transformed declaration >> >> int x = (int) 1; >> >> assuming of course there is no preprocessor funny business. > > Is that real world program? For me real world program has (at > least) 3 mandatory behavioral components ... input, processing > and output. Otherwise what is its real world usage? Also it > isn't defective (that real world programs are as rule). ;) It was only an example of a semantics-preserving transformation. Of course it was meant as only one part of a program, not an entire program. Other parts of the program could do I/O, have possible undefined behavior, etc. >>> Instead "equivalent" means "as useful for its usages". >> >> I am using "equivalent" to mean "having exactly the same >> semantics", which is also what I think Keith Thompson meant. > > OK but it is indeed usually trivial. So people keep saying, more or less, but I haven't seen any kind of supporting argument except proof by assertion. > All trouble that I have met was with undefined behaviors > manifesting differently. What I think you mean is the only trouble that you know you have met was undefined behavior manifesting differently. But, since you aren't sure about all the ways that semantics can vary between C and C++, you don't know if there were other troubles. > Is there some real example of difficulties of translating > semantics of C into semantics of common subset between C and > C++? The question here is not whether some conversions are incredibly difficult but whether most programs can be transformed with a small effort. If converting a program takes two months of full time, even if the work is easy, that is not a small effort. > My experience is that C++ compiler will lament about most places > and additionally warn lot more. The differences that I would > search for manually (and if needed correct or made more explicit) > are const variables linkage, inline functions linkage and usage of > names of structs, unions and enums. Then I would remove any > pointless usage of size of character literals, logical operators, > trues, falses and enums. Finally if there is time then ... I > would refactor away type punning with union despite all C++ > compilers seem to support it. What else? Sure it is work if we > talk about lot of lines of code but easy work. What experience do you have actually trying to convert C code into C++? What can you say about the programs and types of programs that were converted? How long did it take in each case? What evidence can you offer, if any, that the results you saw would apply to all types of real-world programs and not just the programs that you happened to work on?
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
Re: Two different Results between C and C++ Öö Tiib <ootiib@hot.ee> - 2020-09-05 06:51 -0700
Re: Two different Results between C and C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-09-08 07:34 -0700
Re: Two different Results between C and C++ Öö Tiib <ootiib@hot.ee> - 2020-09-10 23:47 -0700
Re: Two different Results between C and C++ James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-09-11 10:17 -0400
Re: Two different Results between C and C++ Öö Tiib <ootiib@hot.ee> - 2020-09-11 08:32 -0700
Re: Two different Results between C and C++ James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-09-11 12:03 -0400
Re: Two different Results between C and C++ Öö Tiib <ootiib@hot.ee> - 2020-09-12 02:49 -0700
Re: Two different Results between C and C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-09-12 22:24 -0700
Re: Two different Results between C and C++ Öö Tiib <ootiib@hot.ee> - 2020-09-13 06:25 -0700
Re: Two different Results between C and C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-09-15 05:01 -0700
Re: Two different Results between C and C++ James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-09-15 10:59 -0700
Re: Two different Results between C and C++ Öö Tiib <ootiib@hot.ee> - 2020-09-15 15:58 -0700
csiph-web