Is the usage of reinterpret_cast on a memcpy buffer UB?

Given the code struct A {}; auto obj = new A; std::vector<unsigned char> buffer; buffer.resize(sizeof(obj)); std::memcpy(buffer.data(), &obj, sizeof(obj)); // this copies the pointer, not the object! // … auto ptr = *reinterpret_cast<A**>(buffer.data()); // is this UB? delete ptr; is the usage of reinterpret_cast in this case UB? I would say yes, because memcpy doesn’t start…

Details

snakeyaml skip root nodes from yaml

I have following yaml db: domain1: host: somehost database: somedb … domain2: … I have following POJO: @Getter @Setter public class PostgresDatabaseConfiguration { private String host; private String database; … } I have following Java code: return new Yaml(new Constructor(PostgresDatabaseConfiguration.class)).load(myYaml) How would I say to snakeyaml to use part of Yaml and navigate to db:…

Details

DateTime.TryParse() and DateTime.TryParseExact() doesn’t parse date on linux/macos and work properly on windows

I try to parse a date that has format “Вс, 1 дек 2019 20:40:00 +0300” (Russian language) dotnet core 3.1 and both TryParse() and TryParseExact() work properly on windows but don’t at linux and macos. I tried different formats and different DateTimeStyles, current culture and used System.Globalization.CultureInfo.GetCultureInfo(“ru-RU”) for getting russian language culture object. Tried it…

Details