Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #154480

Re: Two different Results between C and C++

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 03:13 -0700
Organization A noiseless patient Spider
Message-ID <86sgbx7sui.fsf@linuxsc.com> (permalink)
References (2 earlier) <rb5v6i$pv5$1@dont-email.me> <60d0f73c-8588-4673-a48d-e5c4cc726196@googlegroups.com> <87blm1wam0.fsf@nosuchdomain.example.com> <86d05skg6z.fsf@linuxsc.com> <87tuz4gt4c.fsf@nosuchdomain.example.com>

Show all headers | View raw


Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> 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.

So you meant to consider only those C programs that have actually
been written, rather than making a statement that would apply to
any well-formed C program?  So the statement was meant in the
sense of "almost all existing programs" that are well-formed C?

> My statement was not an "article of faith".  It was somewhat
> speculative.

I am not offering any judgment on whether your statement actually
is an article of faith for you;  nor would I, since I cannot know
what you are thinking.  However, since you did not offer, and still
have not offered, any sort of evidence or reasoning that supports
the assertion, it does come across that way.  You saying that the
statement was somewhat speculative, without saying anything more
specific, doesn't lessen that impression.

Incidentally, I don't know why you put the phrase article of faith
in scare quotes.  It's an established phrase in regular English,
dating back at least 500 years.  A typical definition is "a
deeply held belief".

> I think it was correct, but it's not worth the effort to
> perform a major research project to verify it.

Let's think about what you're saying.  How many C programs have
actually been written?  A hundred thousand?  A million?  Of those,
how many have you actually looked at?  Probably a few hundred, but
let's guess a thousand.  Of the C programs you've seen, how many
have you actually tried to convert to C++?  Five?  Ten?  Twenty?
Assuming the number is 20 and that 200,000 C programs have been
written, that is 0.01%.  Furthermore getting a C program to the
point where it will compile as C++ is not the same as it being the
same program.  Even if we know the semantics of the C program was
not changed by modifying it, there remains the question of whether
the program has the same semantics in C++.  Do you think you know
all the ways that well-formed C code can have different semantics
when compiled as C++?  If you don't, then we shouldn't have much
confidence in your estimate of the effort required to accomplish
the modification, since we don't know whether the goal was actually
reached.  Is this what you mean when you say your claim is somewhat
speculative?  If it is then the word "somewhat" seems vastly
understated.

Back to comp.lang.c | Previous | NextNext in thread | Find similar


Thread

Re: Two different Results between C and C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-09-04 03:13 -0700
  Re: Two different Results between C and C++ Kaz Kylheku <793-849-0957@kylheku.com> - 2020-09-04 18:44 +0000
    Re: Two different Results between C and C++ David Brown <david.brown@hesbynett.no> - 2020-09-05 15:57 +0200
    Re: Two different Results between C and C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-09-08 08:27 -0700
      Re: Two different Results between C and C++ James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-09-08 17:50 -0700
        Re: Two different Results between C and C++ James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-09-08 21:07 -0400
        Re: Two different Results between C and C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-09-08 18:28 -0700
          Re: Two different Results between C and C++ James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-09-08 22:14 -0400
        Re: Two different Results between C and C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-09-10 06:35 -0700
  Re: Two different Results between C and C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-09-04 11:46 -0700
    Re: Two different Results between C and C++ Kaz Kylheku <793-849-0957@kylheku.com> - 2020-09-04 19:07 +0000
    Re: Two different Results between C and C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-09-10 04:15 -0700
      Re: Two different Results between C and C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-09-10 12:46 -0700

csiph-web