From c6c54e710ffd6a87b01dc3992f3e0d393fe54067 Mon Sep 17 00:00:00 2001 From: Albert J wong Date: Thu, 29 Dec 2016 23:39:32 -0800 Subject: [PATCH] Use correct cast for downcasting reference. For downcasting, static_cast<> is the appropriate cast. Using reinterpret_cast<> will NOT correctly adjust the `this` pointer and dereferencing such a value is undefined by spec. See [expr.reinterpret.cast]p7 for the relevant passage. The only legal use of this pointer is in another set of reinterpret_cast expressions that either land it into a numeric value, or back to the original type. --- libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp index 5cb4f8fc4..49c1bbca3 100644 --- a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp +++ b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp @@ -63,7 +63,7 @@ public: bool verify(WiFiClient& client, const char* host) override { - auto wcs = reinterpret_cast(client); + auto wcs = static_cast(client); return wcs.verify(_fingerprint.c_str(), host); }