Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Two different Results between C and C++ Date: Mon, 29 Jun 2020 17:48:01 -0700 Organization: None to speak of Lines: 60 Message-ID: <877dvpe5vi.fsf@nosuchdomain.example.com> References: <8c6495f9-6139-464e-ac8f-4eac27a92776@googlegroups.com> <60d0f73c-8588-4673-a48d-e5c4cc726196@googlegroups.com> <87blm1wam0.fsf@nosuchdomain.example.com> <86d05skg6z.fsf@linuxsc.com> <87tuz4gt4c.fsf@nosuchdomain.example.com> <5efa13c5.237203@news.xs4all.nl> <875zb9g2gw.fsf@nosuchdomain.example.com> <5efa5fb9.19680734@news.xs4all.nl> <5efa7be4$0$1465$e4fe514c@textnews.kpn.nl> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="32e2e984330eca555d58c972980fece0"; logging-data="25595"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19YFrv0a6W+osgs8f1giUY6" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cancel-Lock: sha1:pRMDqGE+PFJWTH5ye8C0DisDQhA= sha1:eo+7KVv9IFneGsDyMdpoS6BcfJU= Xref: csiph.com comp.lang.c:153010 Sjouke Burry writes: > On 30.06.20 0:53, James Kuyper wrote: >> On 6/29/20 5:46 PM, Richard Bos wrote: >>> Keith Thompson wrote: >> ... >>>> But almost all programs that are legal C but not legal C++ can be >>>> made into legal C++ with a small effort. >>>> >>>> At no time did I suggest it would be a good idea. >>> >>> If you had added _that_, I would not have disagreed. It is the crucial >>> point. >> >> Why should he need to add that? Why wasn't a complete failure to make >> any such suggestion sufficient? >> >>> Yes, there is a considerable overlap between C and C++. All second-year >>> programmers know that. It takes a professional to learn that very little >>> in that overlap is useful or interesting, >> >> I find that knowing that the expression a+b specifies that the value of >> a should be added to the value of b is very useful, and it is equally >> true of both C and C++. Both languages add complications to that >> description, but in the context of types that can be expressed in C, >> those complications (such as the integer promotion rules and the usual >> arithmetic conversions) are quite similar. >> >> There's literally thousands of other similar features of C that are also >> features of C++; in total, those features constitute an overwhelming >> majority of the features that C possesses, and it's impossible to write >> any significant amount of C++ code without making frequent use of those >> features. So your description of that overlap as not being useful sounds >> quite weird to me. I think that you're so familiar with those features >> that they have become effectively invisible to you. >> >>> ... and we should not encourage >>> beginning programmers to believe that casting malloc() or relying on the >>> sizes of character constants is a good idea. >> >> No one has suggested anything of the kind, and I'm curious what gave you >> the impression that anyone had. >> > The meaning of a+b in c++ can be completely redefined, like > linking string a and string b . > Anything you read in a c++ program might have been obfuscated. As James wrote: Both languages add complications to that description, but in the context of types that can be expressed in C, those complications (such as the integer promotion rules and the usual arithmetic conversions) are quite similar. The meaning of a+b *when it's a valid C expression* cannot be redefined in C++. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Philips Healthcare void Void(void) { Void(); } /* The recursive call of the void */