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

core/units: remove space before literal identifier #2515

Closed
wants to merge 1 commit into from

Conversation

tchaikov
Copy link
Contributor

clang 20 complains:

/home/kefu/dev/seastar/include/seastar/core/units.hh:37:29: warning: identifier '_KiB' preceded by whitespace in a literal operator declaration is deprecated [-Wdeprecated-literal-operator]
   37 | constexpr size_t operator"" _KiB(unsigned long long n) { return n << 10; }
      |                  ~~~~~~~~~~~^~~~
      |                  operator""_KiB
/home/kefu/dev/seastar/include/seastar/core/units.hh:38:29: warning: identifier '_MiB' preceded by whitespace in a literal operator declaration is deprecated [-Wdeprecated-literal-operator]
   38 | constexpr size_t operator"" _MiB(unsigned long long n) { return n << 20; }
      |                  ~~~~~~~~~~~^~~~
      |                  operator""_MiB
/home/kefu/dev/seastar/include/seastar/core/units.hh:39:29: warning: identifier '_GiB' preceded by whitespace in a literal operator declaration is deprecated [-Wdeprecated-literal-operator]
   39 | constexpr size_t operator"" _GiB(unsigned long long n) { return n << 30; }
      |                  ~~~~~~~~~~~^~~~
      |                  operator""_GiB
/home/kefu/dev/seastar/include/seastar/core/units.hh:40:29: warning: identifier '_TiB' preceded by whitespace in a literal operator declaration is deprecated [-Wdeprecated-literal-operator]
   40 | constexpr size_t operator"" _TiB(unsigned long long n) { return n << 40; }
      |                  ~~~~~~~~~~~^~~~
      |                  operator""_TiB

because, in
CWG2521, it proposes that compiler should consider

  string operator "" _i18n(const char*, std::size_t); // OK, deprecated

as "OK, deprecated".

and Clang implemented this proposal, as it was accepted by C++23.
Since Seastar supports both C++20 and C++23 standards. let's remove the space between " and _ to be more compliant to the C++23 standard and to silence the warning.

clang 20 complains:
```
/home/kefu/dev/seastar/include/seastar/core/units.hh:37:29: warning: identifier '_KiB' preceded by whitespace in a literal operator declaration is deprecated [-Wdeprecated-literal-operator]
   37 | constexpr size_t operator"" _KiB(unsigned long long n) { return n << 10; }
      |                  ~~~~~~~~~~~^~~~
      |                  operator""_KiB
/home/kefu/dev/seastar/include/seastar/core/units.hh:38:29: warning: identifier '_MiB' preceded by whitespace in a literal operator declaration is deprecated [-Wdeprecated-literal-operator]
   38 | constexpr size_t operator"" _MiB(unsigned long long n) { return n << 20; }
      |                  ~~~~~~~~~~~^~~~
      |                  operator""_MiB
/home/kefu/dev/seastar/include/seastar/core/units.hh:39:29: warning: identifier '_GiB' preceded by whitespace in a literal operator declaration is deprecated [-Wdeprecated-literal-operator]
   39 | constexpr size_t operator"" _GiB(unsigned long long n) { return n << 30; }
      |                  ~~~~~~~~~~~^~~~
      |                  operator""_GiB
/home/kefu/dev/seastar/include/seastar/core/units.hh:40:29: warning: identifier '_TiB' preceded by whitespace in a literal operator declaration is deprecated [-Wdeprecated-literal-operator]
   40 | constexpr size_t operator"" _TiB(unsigned long long n) { return n << 40; }
      |                  ~~~~~~~~~~~^~~~
      |                  operator""_TiB
```

because, in
[CWG2521](https://wg21.link/CWG2521), it proposes that compiler should consider
```c++
  string operator "" _i18n(const char*, std::size_t); // OK, deprecated
```
as "OK, deprecated".

and Clang implemented this proposal, as it was accepted by
[C++23](https://eel.is/c++draft/over.literal).
Since Seastar supports both C++20 and C++23 standards. let's remove the
space between `"` and `_` to be more compliant to the C++23 standard and
to silence the warning.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
@xemul xemul closed this in 47c52cb Oct 24, 2024
@tchaikov tchaikov deleted the unit-literal branch October 24, 2024 08:26
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