Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

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

@xingx1

Description

@xingx1

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions