Skip to content

Fix function call in constinit section. #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CPP20.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,10 @@ char8_t utf8_str[] = u8"\u0123";
The `constinit` specifier requires that a variable must be initialized at compile-time.
```c++
const char* g() { return "dynamic initialization"; }
constexpr const char* f(bool p) { return p ? "constant initializer" : g(); }
constexpr const char* f() { return "constant initializer"; }

constinit const char* c = f(true); // OK
constinit const char* d = g(false); // ERROR: `g` is not constexpr, so `d` cannot be evaluated at compile-time.
constinit const char* c = f(); // OK
constinit const char* d = g(); // ERROR: `g` is not constexpr, so `d` cannot be evaluated at compile-time.
```

### \_\_VA\_OPT\_\_
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,10 @@ char8_t utf8_str[] = u8"\u0123";
The `constinit` specifier requires that a variable must be initialized at compile-time.
```c++
const char* g() { return "dynamic initialization"; }
constexpr const char* f(bool p) { return p ? "constant initializer" : g(); }
constexpr const char* f() { return "constant initializer"; }

constinit const char* c = f(true); // OK
constinit const char* d = g(false); // ERROR: `g` is not constexpr, so `d` cannot be evaluated at compile-time.
constinit const char* c = f(); // OK
constinit const char* d = g(); // ERROR: `g` is not constexpr, so `d` cannot be evaluated at compile-time.
```

### \_\_VA\_OPT\_\_
Expand Down