Because 0.8 can't be exactly represented in a finite number of bits to the right of the binary point ... just like 1/7 can't exactly represented by a finite number of digits to the right of the decimal point.
In general, any floating point representation is inexact wrt decimal representation, and you need to account for that when using them. e.g Float is not suitable for currency values, where you want exact decimal representation.
With that code, the compiler will most likely do the comparison at compile-time and hard-code the result of the if statement.
Which Arduino board are you using? With an UNO, compiling with Arduino IDE 1.8.19, the code is printing as expected (the if statement is false). < edit > Ah, I see that I am apparently blind.
GCC option -Wdouble-promotion does that (not included in -Wall -Wextra).
aa.cpp: In function ‘void loop()’:
aa.cpp:23:9: warning: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Wdouble-promotion]
23 | if (y > 0.8)
| ~~^~~~~