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

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

Closed
wants to merge 1 commit into from

Conversation

pateldeev
Copy link
Contributor

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
Copy link

codecov-commenter commented Jan 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Additional details and impacted files
@@            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 Coverage Δ
src/glog/logging.h 64.28% <ø> (ø)

... and 1 file with indirect coverage changes

@sergiud
Copy link
Collaborator

sergiud commented Jan 11, 2024

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
Copy link
Collaborator

sergiud commented Jan 22, 2024

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

@sergiud sergiud closed this Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants