Bug in 2.4.0 ESP8266 Arduino core so use the latest repository.
See https://github.com/esp8266/Arduino/issues/3970