Problem with aggregate initialization of std::string
Created by: mattiasm83
There seems to be a problem with aggregate initialization of std::string.
The variables b and c in the code below uses this:
std::string a = mqttConf[F("server")];
std::string b = {mqttConf[F("server")]};
std::string c{mqttConf[F("server")]};
Serial.println("----");
Serial.println(a.c_str());
Serial.println(b.c_str());
Serial.println(c.c_str());
Serial.println("----");
The output of the following code shows this:
----
192.168.1.1
----
Only the first initialization works.
If I use explicit casts to std::string on the aggregate intializations, like this:
std::string a = mqttConf[F("server")];
std::string b = {mqttConf[F("server")].as<std::string>()};
std::string c{mqttConf[F("server")].as<std::string>()};
then the output shows this (the expected output):
----
192.168.1.1
192.168.1.1
192.168.1.1
----
It this a known limitation, or is it a bug?