Q:

C++ warning: division of double by zero

Case 1:
#include <iostream>

int main()
{
    double d = 15.50;
    std::cout<<(d/0.0)<<std::endl;
}

It compiles without any warnings and prints inf. OK, C++ can handle division by zero, (see it live).
But,
Case 2: 
#include <iostream>

int main()
{
    double d = 15.50;
    std::cout<<(d/0)<<std::endl;
}

The compiler gives the following warning (see it live):
warning: division by zero [-Wdiv-by-zero]
     std::cout<<(d/0)<<std::endl;

Why does the compiler give a warning in the second case? 
Is 0 != 0.0?
Edit:
#include <iostream>

int main()
{
    if(0 == 0.0)
        std::cout<<"Same"<<std::endl;
    else
        std::cout<<"Not same"<<std::endl;
}

output:
Same

A:

Floating point division by zero is well defined by IEEE and gives infinity (either positive or negative according to the value of the numerator (or NaN for ±0) ).
For integers, there is no way to represent infinity and the language defines the operation to have undefined behaviour so the compiler helpfully tries to steer you clear from that path.
However in this case, since the numerator is a double, the divisor (0) should be promoted to a double too and there's no reason to give a warning here whilst not giving a warning for 0.0 so I think this is a compiler bug.

A:

In Standard C++, both cases are undefined behaviour. Anything may happen, including formatting your hard drive.  You should not expect or rely on "return inf. Ok" or any other behaviour.
The compiler apparently decides to give a warning in one case and not the other, but this doesn't mean that one code is OK and one isn't. It is just a quirk of the compiler's generation of warnings.
From the C++17 standard [expr.mul]/4:

The binary / operator yields the quotient, and the binary % operator yields the remainder from the division of the first expression by the second. If the second operand of / or % is zero the behavior is undefined.

A:

My best guess to answer this particular question would be that compiler emits warning before performing conversion of int to double.
So, the steps would be like this:

Parse expression
Arithmetic operator /(T, T2), where T=double, T2=int.
Check that std::is_integral<T2>::value is true and b == 0 - this triggers warning.
Emit warning
Perform implicit conversion of T2 to double 
Perform well defined division (since compiler decided to use IEEE 754).

This is of course speculation and is based on compiler-defined specifications. From standard point of view, we're dealing with possible Undefined Behaviours.

Please note that this is expected behaviour according to GCC documentation
(btw. it seems that this flag can't be used explicitly in GCC 8.1)

-Wdiv-by-zero
      Warn about compile-time integer division by zero. This is default. To inhibit the warning messages, use -Wno-div-by-zero. Floating point
  division by zero is not warned about, as it can be a legitimate way of
  obtaining infinities and NaNs.

