String variable still working after the destructor is called.
So, I have this code
#include<iostream>
#include<string>
using str = std::string;
int main(){
str x;
x = "Hi";
x.~str();
std::cout << x;
}
And it works, which i don't expect it to. Can anyone explain why is that so?
Also, it throws up this runtime error when i make the string longer
free(): double free detected in tcache 2
I know explicitly calling the destructor is not recommended, but i am curious what's happening here both times (when it runs and when it errors out and why are there two outcomes depending on the length of string), (i suspect there is SSO is at work here)