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

compile error: use of overloaded operator '<<' is ambiguous #562

Closed
xingx1 opened this issue Jun 30, 2020 · 2 comments · Fixed by #641
Closed

compile error: use of overloaded operator '<<' is ambiguous #562

xingx1 opened this issue Jun 30, 2020 · 2 comments · Fixed by #641

Comments

@xingx1
Copy link

xingx1 commented Jun 30, 2020

I'm using Ubuntu 18.04.4 LTS (Bionic Beaver), clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final), cmake version 3.10.2.
I cloned, compiled, installed the project, and trying to use it in my own project.
But once I included the header "glog/logging.h", I got an compile error like:

_/usr/local/include/glog/logging.h:649:9: error: use of overloaded operator '<<' is ambiguous 
(with operand types 'std::ostream' (aka 'basic_ostream<char>') and 'const nullptr_t')
  (*os) << v;_

Did this because the use of the operator is really ambiguous or there's implicit incompatible with some cmake settings I made?


I found it is because that CHECK_NE() is not suitable to estimate a pointer to nullptr.
Try following code:

#include "glog/logging.h"
#include <iostream>

int main() {
    int i = 0;
    CHECK_NE(&i, nullptr);
    return 0;
}
Mizux added a commit to google/or-tools that referenced this issue Aug 10, 2020
Mizux added a commit to google/or-tools that referenced this issue Aug 11, 2020
Mizux added a commit to google/or-tools that referenced this issue Aug 11, 2020
Mizux added a commit to google/or-tools that referenced this issue Aug 11, 2020
Mizux added a commit to google/or-tools that referenced this issue Aug 14, 2020
@Mizux
Copy link
Contributor

Mizux commented Oct 19, 2020

Got this bug on Google OR-Tools too. It may come from the version of the gcc compiler

Result I got:

  • alpine, archlinux, fedora OK (gcc 10.2)
  • ubuntu OK (gcc 9.3)
  • centos FAIL (gcc 8.3.1)
  • debian FAIL (gcc 8.3.0)

ref: https://github.com/google/or-tools/actions/runs/315808746

  • runner ubuntu github FAIL (gcc 7.5.0)

ref: https://github.com/google/or-tools/runs/1276111332?check_suite_focus=true

@Mizux
Copy link
Contributor

Mizux commented Oct 20, 2020

FYI, a simple workaround, is to replace:

  • CHECK_NE(..., nullptr) by CHECK(... != nullptr) and
  • CHECK_EQ(..., nullptr) by CHECK(... == nullptr)

Otherwise you may also cherry pick the PR #342

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 a pull request may close this issue.

2 participants