Skip to content

Use operator""sv to ensure string_view are initialized correctly#321

Closed
janisozaur wants to merge 1 commit intomicrosoft:masterfrom
janisozaur:string_view_ops
Closed

Use operator""sv to ensure string_view are initialized correctly#321
janisozaur wants to merge 1 commit intomicrosoft:masterfrom
janisozaur:string_view_ops

Conversation

@janisozaur
Copy link
Copy Markdown
Contributor

Addresses following warning raised by clang:

src/CalcManager/CEngine/scidisp.cpp:23:24: error: constexpr variable 'c_decPreSepStr' must be initialized by a constant expression
constexpr wstring_view c_decPreSepStr = L"[+-]?(\\d*)[";
                       ^                ~~~~~~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/bits/char_traits.h:431:11: note: non-constexpr function 'wcslen' cannot be used in a constant expression
          return wcslen(__s);
                 ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/string_view:100:39: note: in call to 'length(&L"[+-]?(\\d*)["[0])'
      : _M_len{__str == nullptr ? 0 : traits_type::length(__str)},
                                      ^

Description of the changes:

  • Addresses a warning raised by clang. I'm not 100% positive it's not a bug in the STL implementation used by my compiler, but doesn't cause other issues.

Addresses following warning raised by clang:
```
src/CalcManager/CEngine/scidisp.cpp:23:24: error: constexpr variable 'c_decPreSepStr' must be initialized by a constant expression
constexpr wstring_view c_decPreSepStr = L"[+-]?(\\d*)[";
                       ^                ~~~~~~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/bits/char_traits.h:431:11: note: non-constexpr function 'wcslen' cannot be used in a constant expression
          return wcslen(__s);
                 ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/string_view:100:39: note: in call to 'length(&L"[+-]?(\\d*)["[0])'
      : _M_len{__str == nullptr ? 0 : traits_type::length(__str)},
                                      ^
```
@janisozaur
Copy link
Copy Markdown
Contributor Author

janisozaur commented Mar 16, 2019

By using libc++ instead of libstdc++, I've isolated this to be an issue with the latter. I'll check what's the status in libstdc++ 9 and file a report if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant