google / glog

C++ implementation of the Google logging module
http://google.github.io/glog/
BSD 3-Clause "New" or "Revised" License
6.99k stars 2.05k forks source link

Add r-value overload to LogMessageVoidify to make clang-17 happy with c++20 #1060

Closed pateldeev closed 7 months ago

pateldeev commented 8 months ago

Without this, compilation fails for errors like the following

bazel-out/k8-opt/bin/external/com_google_glog/_virtual_includes/glog/glog/logging.h:705:57: note: expanded from macro 'LOG_IF'
  705 |   !(condition) ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
external/local_config_clang/crosstool/extra_tools/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0/cstddef:140:3: note: candidate function not viable: no known conversion from 'google::LogMessageVoidify' to 'byte' for 1st argument
  140 |   operator&(byte __l, byte __r) noexcept
      |   ^         ~~~~~~~~
external/local_config_clang/crosstool/extra_tools/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0/bits/ios_base.h:83:3: note: candidate function not viable: no known conversion from 'google::LogMessageVoidify' to '_Ios_Fmtflags' for 1st argument
   83 |   operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
      |   ^         ~~~~~~~~~~~~~~~~~
external/local_config_clang/crosstool/extra_tools/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0/bits/ios_base.h:126:3: note: candidate function not viable: no known conversion from 'google::LogMessageVoidify' to '_Ios_Openmode' for 1st argument
  126 |   operator&(_Ios_Openmode __a, _Ios_Openmode __b)
      |   ^         ~~~~~~~~~~~~~~~~~
external/local_config_clang/crosstool/extra_tools/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0/bits/ios_base.h:166:3: note: candidate function not viable: no known conversion from 'google::LogMessageVoidify' to '_Ios_Iostate' for 1st argument
  166 |   operator&(_Ios_Iostate __a, _Ios_Iostate __b)
      |   ^         ~~~~~~~~~~~~~~~~
external/local_config_clang/crosstool/extra_tools/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0/bits/atomic_base.h:107:3: note: candidate function not viable: no known conversion from 'google::LogMessageVoidify' to 'memory_order' for 1st argument
  107 |   operator&(memory_order __m, __memory_order_modifier __mod)
      |   ^         ~~~~~~~~~~~~~~~~
external/local_config_clang/crosstool/extra_tools/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0/future:155:20: note: candidate function not viable: no known conversion from 'google::LogMessageVoidify' to 'launch' for 1st argument
  155 |   constexpr launch operator&(launch __x, launch __y) noexcept
      |                    ^         ~~~~~~~~~~
external/local_config_clang/crosstool/extra_tools/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0/charconv:645:3: note: candidate function not viable: no known conversion from 'google::LogMessageVoidify' to 'chars_format' for 1st argument
  645 |   operator&(chars_format __lhs, chars_format __rhs) noexcept
      |   ^         ~~~~~~~~~~~~~~~~~~
external/local_config_clang/crosstool/extra_tools/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0/bitset:1553:5: note: candidate template ignored: could not match 'bitset<_Nb>' against 'google::LogMessageVoidify'
 1553 |     operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
      |     ^
bazel-out/k8-opt/bin/external/com_google_glog/_virtual_includes/glog/glog/logging.h:1717:8: note: candidate function not viable: expects an lvalue for 1st argument
 1717 |   void operator&(std::ostream&) { }
      |        ^         ~~~~~~~~~~~
codecov-commenter commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (7e6fca9) 59.60% compared to head (fd86cf2) 59.63%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1060 +/- ## ========================================== + Coverage 59.60% 59.63% +0.03% ========================================== Files 19 19 Lines 2604 2604 Branches 914 914 ========================================== + Hits 1552 1553 +1 Misses 712 712 + Partials 340 339 -1 ``` | [Files](https://app.codecov.io/gh/google/glog/pull/1060?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) | Coverage Δ | | |---|---|---| | [src/glog/logging.h](https://app.codecov.io/gh/google/glog/pull/1060?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-c3JjL2dsb2cvbG9nZ2luZy5o) | `64.28% <ø> (ø)` | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/google/glog/pull/1060/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)
sergiud commented 8 months ago

Thanks for the PR.

As I do not see any issue associated with this PR, could you please provide a minimum code example that triggers these overload resolutions errors? Generally, the streams involved should not be moved during logging.

sergiud commented 7 months ago

Closing due to lack of response. Please provide a snippet that causes the issue if you want to purse the PR.