| Deutsch English Français Italiano |
|
<87bk4v2du1.fsf@nosuchdomain.example.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith Thompson <Keith.S.Thompson+u@gmail.com>
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: <v2l828$18v7f$1@dont-email.me>
<00297443-2fee-48d4-81a0-9ff6ae6481e4@gmail.com>
<v2lji1$1bbcp$1@dont-email.me>
<9be0c55c-38f8-496c-b335-84ad281e1753@gmail.com>
<v2nc5h$1oban$1@dont-email.me>
<c5866b5a-0314-4e70-af56-a86b63986b0c@gmail.com>
<v2nfai$1ougd$1@dont-email.me>
<cf267279-e9cf-415f-898c-f5830a997529@gmail.com>
<87ed9s42sb.fsf@nosuchdomain.example.com>
<f5774ff3-d2b0-4787-b16c-3b193dc418ef@gmail.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 <thiago.adams@gmail.com> 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 */