I have a following code:
#include <iostream>
#include <unordered_map>
#include <string>
int main()
{
std::unordered_map<std::string, int> map;
std::cout << map["foo"]; // -> 0
return 0;
}
I am using map["foo"]
without initialisation.
Is this code valid or UB?
Edit: I tried to compile in godbolt and got 0
output with clang and gcc (trunk version) https://godbolt.org/z/KeWq7nbob.