When compiling a solidity smart contract with solcjs, how can I tell if the address address is empty?

the main problem code snippet is as follows:


pragma solidity ^0.4.22;

contract Auction {

    address highestBidder;  //
    
    function bid() public payable{
        require(msg.value < 0.0001 ether,"0.0001 ether");
    
        if(highestBidder != 0){    //
        
        }
    }
}

this contract has no problem compiling and running with truffle , including test, but will report a TypeError error when compiling with solc.

contract/Auction.sol:14:12: TypeError: Operator != not compatible with types address and int_const 0
        if(highestBidder != 0){
           ^----------------^

after searching the Internet, it is found that the default value of all declared variables is 0, so there is no problem with this judgment.
Why does solc report an error?

Update:

I tried to find a solution, at least for now solc did not report wrong. Is to change the judgment to:

if (highestBidder! = address (0)) {

Jan.25,2022

the answer is to use the address () method to judge.

if(highestBidder != address(0)){
}
Menu