Liste des Groupes | Revenir à cl c |
Thiago Adams <thiago.adams@gmail.com> writes:My understanding is that constexpr is a tip for the compiler. Does not ensure anything. Unless you use where constant expression is required.On 23/05/2024 18:49, Keith Thompson wrote:I don't understand. Do you object because it's not *immediately>error: 'constexpr' pointer initializer is not nullWhy not?
5 | constexpr char * s[] = {"a", "b"};
>
>
Then we were asking why constexpr was used in that case.
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.
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.I may have to implement constexpr in cake... So at some point I will see all details.
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 *".
Les messages affichés proviennent d'usenet.