Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: C23 thoughts and opinions Date: Fri, 24 May 2024 12:45:58 -0700 Organization: None to speak of Lines: 28 Message-ID: <87bk4v2du1.fsf@nosuchdomain.example.com> References: <00297443-2fee-48d4-81a0-9ff6ae6481e4@gmail.com> <9be0c55c-38f8-496c-b335-84ad281e1753@gmail.com> <87ed9s42sb.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Fri, 24 May 2024 21:45:58 +0200 (CEST) Injection-Info: dont-email.me; posting-host="9bf1a2728fa7020763691602348055f5"; logging-data="2605436"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ooy5AbDIKhEPvlPjt6c/0" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:56rqRo0ZWrgmJtT0OMOHrtVUPac= sha1:7YrV80Q2GqsyllbwffmFnM4G6Uc= Bytes: 2363 Thiago Adams writes: > On 23/05/2024 18:49, Keith Thompson wrote: >>> error: 'constexpr' pointer initializer is not null >>> 5 | constexpr char * s[] = {"a", "b"}; >>> >>> >>> Then we were asking why constexpr was used in that case. >> Why not? > > When I see a constexpr I ask if the compiler is able to compute > everything at compile time. If not immediately it is a bad usage in my > view. I don't understand. Do you object because it's not *immediately obvious* that everthing can be computed at compile time? If so, why should it have to be? If nothing else, the fact that the code compiles should be proof enough. You said something upthread about the compiler ignoring constexpr if the expression isn't compile-time evaluable; perhaps you were using a buggy compiler? Note that the above code is C++, not C, and that it should be "constexpr const char *". -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */