|
|
|
|
|
by krollew
5074 days ago
|
|
Doesn't "undefined behaviour" means that solution might not be portable? Anyway it looks like a mess. I guess the most of C programmers wouldn't have any idea what that first line of function does and why. If one see restricted he just looks on google what does it mean. Looking for meaning of your solution might be troublesome. |
|
It is only undefined behavior if you call the function with aliasing arguments, which is exactly what you are committing not to do anyway. It is only similar to writing the function in C99 with restrict and then calling it with aliasing pointers: you get garbage but it is your fault.
> Anyway it looks like a mess.
I actually wrote this blog post in reaction to the ongoing debate about the exploitation of undefined behavior by C compilers for optimization. As Tom Duff noted in other circumstances, “This code forms some sort of argument in that debate, but I'm not sure whether it's for or against.”