Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #154487
| From | Tim Rentsch <tr.17687@z991.linuxsc.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Two different Results between C and C++ |
| Date | 2020-09-04 06:44 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <86ft7x7j1h.fsf@linuxsc.com> (permalink) |
| References | (5 earlier) <86d05skg6z.fsf@linuxsc.com> <87tuz4gt4c.fsf@nosuchdomain.example.com> <CnSHG.29905$mK4.29698@fx03.iad> <861rjj8kmz.fsf@linuxsc.com> <a9597fac-1c3d-42bd-bbe4-b82a3d3d8816o@googlegroups.com> |
Tiib <ootiib@hot.ee> writes: > On Thursday, 3 September 2020 09:00:54 UTC+3, Tim Rentsch wrote: > >> Richard Damon <Richard@Damon-Family.org> writes: >> >>> On 6/21/20 2:40 PM, Keith Thompson wrote: >>> >>>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes: >>>> >>>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes: >>>> >>>> [...] >>>> >>>>>> All these statements are true, but none are particularly relevant. >>>>>> You can construct an infinite number of valid C or C++ programs by >>>>>> playing games with the grammar. There are an infinite number of >>>>>> legal C programs that use conditional operators nested 10,000 >>>>>> levels deep, but I doubt that any such programs exist in the wild >>>>>> (except *maybe* as compiler capacity tests). I think it's more >>>>>> useful to look at actual code rather than contrived infinite sets >>>>>> of programs. >>>>>> >>>>>> There are *some* programs that are legal C but not legal C++. The >>>>>> most common causes of this are probably C++'s tighter restrictions >>>>>> on implicit conversions involving void*, C code that uses C++ >>>>>> keywords as identifiers, and C features that haven't been >>>>>> incorporated into C++, such as VLAs, _Generic, and compound >>>>>> literals. But almost all programs that are legal C but not legal >>>>>> C++ can be made into legal C++ with a small effort. >>>>> >>>>> This claim sounds like an article of faith, being offered without >>>>> either proof or evidence. If meant as just an empirical statement >>>>> then of course there is no way anyone can know that. >>>> >>>> When I wrote "almost all programs that are legal C but not legal >>>> C++", I was referring to real-world programs, not the infinite set >>>> of all possible programs. I probably could have made that clearer. >>>> >>>> My statement was not an "article of faith". It was somewhat >>>> speculative. I think it was correct, but it's not worth the effort >>>> to perform a major research project to verify it. >>>> >>>> [...] >>> >>> My experiance would be a bit different, most C programs from the >>> 'wild' would likely fail as C++ precisely because of the implicit >>> conversion from void* that does not happen in C++. These programs >>> can trivially be converted to programs which are valid in both C >>> and C++ by adding the explicit cast. [...] >> >> Lots of C programs fail as C++ because of constraint violations >> or syntax errors. The problems are (obviously) easy to find, >> and mostly I think easy to fix. >> >> The bigger problem is C code that is legal C++ but has different >> semantics in C++ than in C. There are more of these than most >> C or C++ developers think there are. I don't know anyone, >> including myself, who can say with confidence that they know >> all the different ways that source code can have a different >> meaning in C++ compared to C. > > James Kuyper already said somewhere in this thread that C++ standard > lists such differences in Annex C [diff.iso]. It is quite exhaustive > list, may be few obscure cases are missing. The list is not complete. AFAICT it doesn't even try to be complete, or current. >> Clearly if someone doesn't know >> what all the potential discrepancies are there is no way they >> could find and fix them. > > In practice even developer who has never read neither standards nor > that [diff.iso] can do it. There always are at least some tests. > If test fails there is capability to figure it out why it fails. Once > that capability has been applied to fix an issue also knowledge > is obtained how to search for similar from untested parts of code. Testing can be used to show the presence of errors, but never their absence. The code may seem to work even when bugs are still lurking. Also, if a test fails, there is no guarantee we can track down what caused the failure in any reasonably limited amount of time. This is especially true when we don't know what it is we're looking for.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
Re: Two different Results between C and C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-09-02 23:00 -0700
Re: Two different Results between C and C++ Öö Tiib <ootiib@hot.ee> - 2020-09-03 09:57 -0700
Re: Two different Results between C and C++ David Brown <david.brown@hesbynett.no> - 2020-09-03 20:04 +0200
Re: Two different Results between C and C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-09-04 06:44 -0700
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++ James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-09-03 12:46 -0700
Re: Two different Results between C and C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-09-10 06:20 -0700
Re: Two different Results between C and C++ James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-09-10 07:37 -0700
Re: Two different Results between C and C++ James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-09-10 10:44 -0400
csiph-web