Should pointer comparisons be signed or unsigned in 64-bit x86?

TL:DR: intptr_t might be best in some cases because the signed-overflow boundary is in the middle of the “non-canonical hole”. Treating a value as negative instead of huge may be better if wrapping from zero to 0xFF…FF or vice versa is possible, but pointer+size for any valid size can’t wrap a value from INT64_MAX to … Read more

Why does Go forbid taking the address of (&) map member, yet allows (&) slice element?

There is a major difference between slices and maps: Slices are backed by a backing array and maps are not. If a map grows or shrinks a potential pointer to a map element may become a dangling pointer pointing into nowhere (uninitialised memory). The problem here is not “confusion of the user” but that it … Read more

Why does printing a pointer print the same thing as printing the dereferenced pointer?

Rust usually focuses on object value (i.e. the interesting part of the contents) rather than object identity (memory addresses). The implementation of Display for &T where T implements Display defers directly to the contents. Expanding that macro manually for the String implementation of Display: impl<‘a> Display for &’a String { fn fmt(&self, f: &mut Formatter) … Read more

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