All Questions
3
questions
2
votes
2
answers
108
views
error: constexpr pointer initializer is not null
I have this very simple program:
int main(void)
{
static constexpr const char *const str = "hello";
}
which fails to compile with this error:
$ gcc -std=c2x str.c
str.c: In function '...
0
votes
1
answer
107
views
What new types and operations can take place in a constexpr in C23?
C23 added a keyword constexpr which can be used to define objects as compile-time constants instead of enumerations or macros. For example:
constexpr int x = 10;
constexpr int y = x+10; // Valid
...
2
votes
2
answers
2k
views
gcc: constexpr functions in C23?
Playing around with constexpr with GCC v14.0 (which should be close to the soon to be released GCC v13.1), I compiled the following module:
constexpr int f (int x)
{
return x + 2;
}
constexpr ...