Re: C23 thoughts and opinions

Liste des GroupesRevenir à cl c 
Sujet : Re: C23 thoughts and opinions
De : thiago.adams (at) *nospam* gmail.com (Thiago Adams)
Groupes : comp.lang.c
Date : 06. Jun 2024, 19:01:46
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v3stia$1jpih$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
User-Agent : Mozilla Thunderbird
On 25/05/2024 08:19, Thiago Adams wrote:
...

In my view , for this sample constexpr generates noise. It also can make the compilation slower, otherwise, why not everything constexpr by defaul?
I still didn't find a useful usage for constexpr that would compensate the mess created with const, constexpr. I already saw ( I don't have it now ) proposals to make const more like constexpr in C. In C++ const is already a constant expression!
The justification for C was VLA. They should consider VLA not VLA if it has a constant expression. In other words, better break this than create a mess.
#define makes the job of constexpr.
  
One more sample of NOISE of constexpr from the same real source.
int compare(const Node* a, const Node* b)
{
     return memcmp(a, b, sizeof(Node)) == 0;
}
bool IsValid(Node * pnid)
{
     static constexpr Node node = { 1, 2 };
     return compare(pnid, &node);
}
What is expectation passing the address of compile constant to a runtime function? This is pure noise!
Nothing happens, nothing is done at compile time.
https://godbolt.org/z/ecsMf4vaY

Date Sujet#  Auteur
6 Jun 24 o Re: C23 thoughts and opinions1Thiago Adams

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal