Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: constexpr keyword is unnecessary Date: Sat, 19 Oct 2024 14:49:55 -0700 Organization: None to speak of Lines: 46 Message-ID: <87ttd7pxto.fsf@nosuchdomain.example.com> References: <877ca5q84u.fsf@nosuchdomain.example.com> <20241019195305.0000381d@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Sat, 19 Oct 2024 23:49:56 +0200 (CEST) Injection-Info: dont-email.me; posting-host="4632646bb00bcda06c245f19eb191951"; logging-data="46837"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/C1Qy7S86+v5TYVxm+DEpv" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:Nl3E8XzD1W+x/J1nEtTlHNOIqM0= sha1:vM2s15oOmbpKX4k2/B8I6hPc08Y= Xref: csiph.com comp.lang.c:388700 Thiago Adams writes: > Em 10/19/2024 1:53 PM, Michael S escreveu: >> On Sat, 19 Oct 2024 12:18:04 -0300 >> Thiago Adams wrote: >> >>> Em 10/18/2024 8:54 PM, Keith Thompson escreveu: >>>> Thiago Adams writes: >>>>> I think constexpr keyword is unnecessary. >>>> >>>> Sure, most language features are strictly unnecessary. >>>> >>>>> Anything you do with it could/should be done with const. >>>> >>>> No, absolutely not. >>>> >>> >>> If not, do you have a sample where, using "const" as "constexpr", >>> would create problems? >>> >>> The sample I know is VLA. >>> >>> const int c = 2; >>> int a[c]; //a is VLA because c is not a constant expression. >>> >>> >>> But this is not enough to convince me because it is better not to be >>> a VLA here. >>> >>> >>> >> const int c = 2; >> struct bar { >> int a[c]; >> int b; >> }; >> > > Yes, but in this case, you're changing something that was previously > an error into something that now works. Or you can change something that's an error into something that works in C23 by typing "constexpr" rather than "const". -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */