Conversation
Generated via commit 726b126 Download link for the artifact containing the test results: ↓ atime-results.zip
|
|
This seems to crash |
| union { const char *a; char *b; } tmp = { ptr }; | ||
| return tmp.b; | ||
| } | ||
| #define const_cast(x) (((union{typeof(x) a; typeof(+(*(x)))* b;}){.a=(x)}).b) |
There was a problem hiding this comment.
In the issue titled 'awful one liners don't improve readability or performance' (#6995) I see you wrote:
Collapsing everything into one line doesn't make the code run faster, the compiler is smart enough to sort it out.
I wonder what category this belongs to then 🤔
There was a problem hiding this comment.
A fair criticism!
The problem is, I don't think it's even possible to implement it differently since its a macro, and I think const_cast already has a clear enough meaning that the one liner isn't too bad here. It's clear what the code does.

I changed
const_castto be a type agnostic macro, much more in line with the C++ version.