Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Thiago Adams Newsgroups: comp.lang.c Subject: Re: constexpr keyword is unnecessary Date: Sat, 19 Oct 2024 16:35:37 -0300 Organization: A noiseless patient Spider Lines: 43 Message-ID: References: <877ca5q84u.fsf@nosuchdomain.example.com> <20241019195305.0000381d@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 19 Oct 2024 21:35:39 +0200 (CEST) Injection-Info: dont-email.me; posting-host="08acdff8dec93de51a377425374e1364"; logging-data="24815"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18GHlwNpMQGMNZE808yp+jlEhr8mDbdWbA=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:EcPqBbmoxOg2dGddVhu1nPnamec= In-Reply-To: <20241019195305.0000381d@yahoo.com> Content-Language: en-GB Bytes: 2137 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.