If you want to allocate a Meow pointer to a Bark pointer that's your decision. It won't work to your satisfaction, but there's nothing preventing you from doing it. That's why we have programmers. Those people who have the intelligence and skills and know the limitations of a language.
Just like a gun doesn't care if it's pointing at your foot when you pull the trigger, most (all??) programming languages will let you do something stupid if you insist on doing so.
> Just like a gun doesn't care if it's pointing at your foot when you pull the trigger, most (all??) programming languages will let you do something stupid if you insist on doing so.
Well, right, but that's the exact reason why we have stuff like safety switches on guns. While it's your own prerogative if you truly wish to blow your foot off, accidentally injury is something we generally care about preventing. It's not even a question of if kernels written in C have severe memory corruption issues, it's a matter of how many. Many companies have simply given up on trying to find them all and are instead pouring hundreds of millions into making exploitation hard (see: ARM's Pointer Authentication, which is 100% useless unless you expect to encounter memory corruption). While I love C and think it's a great language, "don't shoot your damn foot off, duh" is just something that doesn't work in practice.
A struct pointer is a struct pointer.
If you want to allocate a Meow pointer to a Bark pointer that's your decision. It won't work to your satisfaction, but there's nothing preventing you from doing it. That's why we have programmers. Those people who have the intelligence and skills and know the limitations of a language.
Just like a gun doesn't care if it's pointing at your foot when you pull the trigger, most (all??) programming languages will let you do something stupid if you insist on doing so.