by pkkm on 10/6/24, 3:16 PM with 58 comments
by jandrewrogers on 10/10/24, 6:26 AM
Here is why I don’t blame the developers: writing fast, efficient systems code that satisfies the requirements of strict aliasing as defined by C/C++ is surprisingly difficult. It has taken me years to figure out the technically correct incantations for every weird edge case such that they always satisfy the requirements of strict aliasing. The code gymnastics in some cases are entirely unreasonable. In fairness, recent versions of C++ have been adding ways to express each of these cases directly, eliminating the need to use obtuse incantations. But we still have huge old code bases that assume compiler behavior, as was the practice for decades.
I am not here to attribute blame, I think it the causes are pretty diffuse honestly. This is just a part of the systems world we failed to do well, and it impacts the code we write every day. I see strict aliasing violations in almost every code base I look at.
by sapiogram on 10/10/24, 12:19 PM
by icedchai on 10/10/24, 1:58 PM
by RossBencina on 10/10/24, 10:46 AM
by Gabriel54 on 10/10/24, 12:07 PM
int foo(int *x) {
*x = 0;
// wait until another thread writes to *x
return *x;
}
Can the C compiler really optimize foo to always return 0? That seems extremely unintuitive to me.by dang on 10/11/24, 2:29 AM
The Strict Aliasing Situation Is Pretty Bad - https://news.ycombinator.com/item?id=11288665 - March 2016 (67 comments)