Double free in the C++ standard library using only std::function and std::shared_pointer

I believe the relevant part of the standard is [res.on.objects], which states If an object of a standard library type is accessed, and the beginning of the object’s lifetime does not happen before the access, or the access does not happen before the end of the object’s lifetime, the behavior is undefined unless otherwise specified. … Read more

Copying structs with uninitialized members

Yes, if the uninitialized member is not an unsigned narrow character type or std::byte, then copying a struct containing this indeterminate value with the implicitly defined copy constructor is technically undefined behavior, as it is for copying a variable with indeterminate value of the same type, because of [dcl.init]/12. This applies here, because the implicitly … Read more

In which versions of the C++ standard does “(i+=10)+=10” have undefined behaviour?

tl;dr: The sequence of the modifications and reads performed in (i+=10)+=10 is well defined in both C++98 and C++11, however in C++98 this is not sufficient to make the behavior defined. In C++98 multiple modifications to the same object without an intervening sequence-point results in undefined behavior, even when the order of those modifications is … Read more

Division by zero: Undefined Behavior or Implementation Defined in C and/or C++?

I don’t see any contradiction. Division by zero is undefined, period. There is no mention of “… unless INFINITY is defined” anywhere in the quoted text. Note that nowhere in mathematics it is defined that 1 / 0 = infinity. One might interpret it that way, but it is a personal, “shortcut” style interpretation, rather … Read more

Does the definition int a = 0, b = a++, c = a++; have defined behavior in C?

Does the definition int a = 0, b = a++, c = a++; have defined behavior in C? Yes, because C 2018 6.8 3 says these initializations (not all, see bottom) are evaluated in the order they appear: … The initializers of objects that have automatic storage duration, and the variable length array declarators of … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)