Skip to content
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

Constructing a string_view from string literal uses a call to strlen #107

Open
rmn30 opened this issue Jan 27, 2025 · 0 comments
Open

Constructing a string_view from string literal uses a call to strlen #107

rmn30 opened this issue Jan 27, 2025 · 0 comments
Labels
good first issue Good for newcomers

Comments

@rmn30
Copy link

rmn30 commented Jan 27, 2025

The following code will emit a call to strlen:

std::string_view a {"hello"};

This is a bit surprising because it could be evaluated at compile time. It's slightly annoying because it might require adding the 'strings' library on CHERIoT and obviously is slightly suboptimal from a performance point of view. Using a string_view literal doesn't require this call e.g.

using namespace std::literals;
std::string_view a {"hello"sv};

This is by no means urgent and may be an upstream issue but thought it worth noting.

@davidchisnall davidchisnall added the good first issue Good for newcomers label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants