Re: constexpr keyword is unnecessary

Liste des GroupesRevenir à cl c  
Sujet : Re: constexpr keyword is unnecessary
De : bc (at) *nospam* freeuk.com (Bart)
Groupes : comp.lang.c
Date : 19. Oct 2024, 18:22:11
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vf0ps2$3vf16$1@dont-email.me>
References : 1 2 3 4
User-Agent : Mozilla Thunderbird
On 19/10/2024 17:03, David Brown wrote:
On 19/10/2024 17:18, Thiago Adams wrote:
Em 10/18/2024 8:54 PM, Keith Thompson escreveu:
Thiago Adams <thiago.adams@gmail.com> 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.
>
 What practical difference would it make?  Can you think of any difference between local variables "a" and "b" defined like this?
      enum { n = 2 };
     const int c = n;
     int a[c];
     int b[n];
 Can you show any situation where you could use "a" and not "b", or vice versa, or where the meaning would be different?  Can you show any compiler that treats them differently in code generation (assuming a compiler that supports enough of C99 to allow it)?
 I know of no differences there.  That is enough to convince me that it doesn't matter in the slightest whether it is technically a VLA or not.
I can give examples where a compiler won't work, or it will generate different code, but you won't execpt it because you won't recognise the compiler, or will dismiss it, or will dismiss even gcc because optimisations aren't used.
If it will always be gcc-O2 or higher, and it is an example just like these (so inside a function), then probably it will generate the same code.
But that's a lot of 'if's.
Where the code is different, then gcc on Windows for example likes to generate a call to __chkstack() (to incrementally increase the stack a page at a time in case it skips a page for a large allocation).

Date Sujet#  Auteur
11 Oct 24 * constexpr keyword is unnecessary106Thiago Adams
11 Oct 24 +* Re: constexpr keyword is unnecessary25Bonita Montero
11 Oct 24 i`* Re: constexpr keyword is unnecessary24Thiago Adams
11 Oct 24 i `* Re: constexpr keyword is unnecessary23Bonita Montero
11 Oct 24 i  `* Re: constexpr keyword is unnecessary22Thiago Adams
12 Oct 24 i   +* Re: constexpr keyword is unnecessary16Bonita Montero
12 Oct 24 i   i`* Re: constexpr keyword is unnecessary15Thiago Adams
12 Oct 24 i   i `* Re: constexpr keyword is unnecessary14Bonita Montero
12 Oct 24 i   i  `* Re: constexpr keyword is unnecessary13Thiago Adams
13 Oct 24 i   i   `* Re: constexpr keyword is unnecessary12Bonita Montero
13 Oct 24 i   i    +* Re: constexpr keyword is unnecessary2Thiago Adams
13 Oct 24 i   i    i`- Re: constexpr keyword is unnecessary1Bonita Montero
15 Oct 24 i   i    `* Re: constexpr keyword is unnecessary9DFS
15 Oct 24 i   i     `* Re: constexpr keyword is unnecessary8Bonita Montero
15 Oct 24 i   i      `* Re: constexpr keyword is unnecessary7Bart
15 Oct 24 i   i       +* Re: constexpr keyword is unnecessary3Thiago Adams
15 Oct 24 i   i       i+- Re: constexpr keyword is unnecessary1Bonita Montero
16 Oct 24 i   i       i`- Re: constexpr keyword is unnecessary1Janis Papanagnou
15 Oct 24 i   i       `* Re: constexpr keyword is unnecessary3Kaz Kylheku
16 Oct 24 i   i        +- Re: constexpr keyword is unnecessary1Bonita Montero
16 Oct 24 i   i        `- Re: constexpr keyword is unnecessary1Janis Papanagnou
13 Oct 24 i   `* Re: constexpr keyword is unnecessary5Kaz Kylheku
13 Oct 24 i    `* Re: constexpr keyword is unnecessary4Thiago Adams
13 Oct 24 i     +- Re: constexpr keyword is unnecessary1Bonita Montero
13 Oct 24 i     `* Re: constexpr keyword is unnecessary2Kaz Kylheku
13 Oct 24 i      `- Re: constexpr keyword is unnecessary1Thiago Adams
12 Oct 24 +* Re: constexpr keyword is unnecessary21Bart
12 Oct 24 i`* Re: constexpr keyword is unnecessary20Thiago Adams
13 Oct 24 i `* Re: constexpr keyword is unnecessary19Bart
13 Oct 24 i  `* Re: constexpr keyword is unnecessary18Thiago Adams
13 Oct 24 i   `* Re: constexpr keyword is unnecessary17Bonita Montero
13 Oct 24 i    `* Re: constexpr keyword is unnecessary16Thiago Adams
13 Oct 24 i     +* Re: constexpr keyword is unnecessary11Bonita Montero
13 Oct 24 i     i`* Re: constexpr keyword is unnecessary10Thiago Adams
13 Oct 24 i     i `* Re: constexpr keyword is unnecessary9Bonita Montero
13 Oct 24 i     i  `* Re: constexpr keyword is unnecessary8Janis Papanagnou
13 Oct 24 i     i   `* Re: constexpr keyword is unnecessary7Bonita Montero
13 Oct 24 i     i    `* Re: constexpr keyword is unnecessary6Janis Papanagnou
13 Oct 24 i     i     `* Re: constexpr keyword is unnecessary5Bonita Montero
13 Oct 24 i     i      +* Re: constexpr keyword is unnecessary2Thiago Adams
13 Oct 24 i     i      i`- Re: constexpr keyword is unnecessary1Bonita Montero
13 Oct 24 i     i      `* Re: constexpr keyword is unnecessary2Janis Papanagnou
13 Oct 24 i     i       `- Re: constexpr keyword is unnecessary1Bonita Montero
13 Oct 24 i     `* Re: constexpr keyword is unnecessary4Michael S
13 Oct 24 i      `* Re: constexpr keyword is unnecessary3Thiago Adams
13 Oct 24 i       `* Re: constexpr keyword is unnecessary2Michael S
13 Oct 24 i        `- Re: constexpr keyword is unnecessary1Thiago Adams
19 Oct 24 `* Re: constexpr keyword is unnecessary59Keith Thompson
19 Oct 24  +- Re: constexpr keyword is unnecessary1Bonita Montero
19 Oct 24  `* Re: constexpr keyword is unnecessary57Thiago Adams
19 Oct 24   +* Re: constexpr keyword is unnecessary53David Brown
19 Oct 24   i+* Re: constexpr keyword is unnecessary9Bart
20 Oct 24   ii`* Re: constexpr keyword is unnecessary8David Brown
20 Oct 24   ii `* Re: constexpr keyword is unnecessary7Keith Thompson
21 Oct 24   ii  +- Re: constexpr keyword is unnecessary1Opus
21 Oct 24   ii  `* Re: constexpr keyword is unnecessary5David Brown
21 Oct 24   ii   `* Re: constexpr keyword is unnecessary4Keith Thompson
21 Oct 24   ii    `* Re: constexpr keyword is unnecessary3Chris M. Thomasson
22 Oct 24   ii     `* Re: constexpr keyword is unnecessary2Kaz Kylheku
22 Oct 24   ii      `- Re: constexpr keyword is unnecessary1Chris M. Thomasson
19 Oct 24   i+* Re: constexpr keyword is unnecessary40Thiago Adams
19 Oct 24   ii+* Re: constexpr keyword is unnecessary36Keith Thompson
20 Oct 24   iii+* Re: constexpr keyword is unnecessary33Thiago Adams
20 Oct 24   iiii`* Re: constexpr keyword is unnecessary32Keith Thompson
20 Oct 24   iiii +- Re: constexpr keyword is unnecessary1Michael S
20 Oct 24   iiii `* Re: constexpr keyword is unnecessary30Thiago Adams
22 Oct 24   iiii  `* Re: constexpr keyword is unnecessary29Bonita Montero
22 Oct 24   iiii   `* Re: constexpr keyword is unnecessary28Thiago Adams
26 Oct 24   iiii    `* Re: constexpr keyword is unnecessary27Vir Campestris
26 Oct 24   iiii     +* Re: constexpr keyword is unnecessary24James Kuyper
26 Oct 24   iiii     i+* Re: constexpr keyword is unnecessary6Janis Papanagnou
27 Oct 24   iiii     ii`* Re: constexpr keyword is unnecessary5Tim Rentsch
4 Nov 24   iiii     ii `* Re: constexpr keyword is unnecessary4Tim Rentsch
4 Nov 24   iiii     ii  `* Re: constexpr keyword is unnecessary3Lowell Gilbert
4 Nov 24   iiii     ii   +- Re: constexpr keyword is unnecessary1Kaz Kylheku
7 Nov 24   iiii     ii   `- Re: constexpr keyword is unnecessary1Tim Rentsch
27 Oct 24   iiii     i+* Re: constexpr keyword is unnecessary2Tim Rentsch
27 Oct 24   iiii     ii`- Re: constexpr keyword is unnecessary1David Brown
27 Oct 24   iiii     i+- Re: constexpr keyword is unnecessary1David Brown
28 Oct 24   iiii     i`* Re: constexpr keyword is unnecessary14Kaz Kylheku
28 Oct 24   iiii     i `* Re: constexpr keyword is unnecessary13Thiago Adams
29 Oct 24   iiii     i  +* Re: constexpr keyword is unnecessary10Kaz Kylheku
29 Oct 24   iiii     i  i+* Re: constexpr keyword is unnecessary8Thiago Adams
29 Oct 24   iiii     i  ii+* Re: constexpr keyword is unnecessary5Thiago Adams
29 Oct 24   iiii     i  iii`* Re: constexpr keyword is unnecessary4David Brown
29 Oct 24   iiii     i  iii +* Re: constexpr keyword is unnecessary2Thiago Adams
29 Oct 24   iiii     i  iii i`- Re: constexpr keyword is unnecessary1David Brown
30 Oct 24   iiii     i  iii `- Re: constexpr keyword is unnecessary1Janis Papanagnou
29 Oct 24   iiii     i  ii`* Re: constexpr keyword is unnecessary2Kaz Kylheku
5 Nov 24   iiii     i  ii `- Re: constexpr keyword is unnecessary1Tim Rentsch
5 Nov 24   iiii     i  i`- Re: constexpr keyword is unnecessary1Tim Rentsch
29 Oct 24   iiii     i  `* Re: constexpr keyword is unnecessary2Richard Harnden
29 Oct 24   iiii     i   `- Re: constexpr keyword is unnecessary1Thiago Adams
27 Oct 24   iiii     `* Re: constexpr keyword is unnecessary2Tim Rentsch
27 Oct 24   iiii      `- Re: constexpr keyword is unnecessary1David Brown
20 Oct 24   iii`* Re: constexpr keyword is unnecessary2Thiago Adams
20 Oct 24   iii `- Re: constexpr keyword is unnecessary1Bonita Montero
20 Oct 24   ii`* Re: constexpr keyword is unnecessary3David Brown
20 Oct 24   ii `* Re: constexpr keyword is unnecessary2Bart
20 Oct 24   ii  `- Re: constexpr keyword is unnecessary1David Brown
19 Oct 24   i`* Re: constexpr keyword is unnecessary3Keith Thompson
19 Oct 24   `* Re: constexpr keyword is unnecessary3Michael S

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal