Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why do people worry so much about pointer casts and/or reference casts?

0
10 Posted

Why do people worry so much about pointer casts and/or reference casts?

0

Because they’re evil! (Which means you should use them sparingly and with great care.) For some reason, programmers are sloppy in their use of pointer casts. They cast this to that all over the place, then they wonder why things don’t quite work right. Here’s the worst thing: when the compiler gives them an error message, they add a cast to “shut the compiler up,” then they “test it” to see if it seems to work. If you have a lot of pointer casts or reference casts, read on. The compiler will often be silent when you’re doing pointer-casts and/or reference casts. Pointer-casts (and reference-casts) tend to shut the compiler up. I think of them as a filter on error messages: the compiler wants to complain because it sees you’re doing something stupid, but it also sees that it’s not allowed to complain due to your pointer-cast, so it drops the error message into the bit-bucket. It’s like putting duct tape on the compiler’s mouth: it’s trying to tell you something important, but you’ve int

0

[Recently created (in 8/01). Click here to go to the next FAQ in the “chain” of recent changes.] Because they’re evil! (Use them sparingly and with great care.) For some reason, programmers are sloppy in their use of pointer casts. They cast this to that all over the place, then they wonder why things don’t quite work right. Here’s the worst thing: when the compiler gives them an error message, they add a cast to “shut the compiler up,” then they “test it” to see if it seems to work. If you have a lot of pointer casts or reference casts, read on. The compiler will often be silent when you’re doing pointer-casts and/or reference casts. Pointer-casts (and reference-casts) tend to shut the compiler up. I think of them as a filter on error messages: the compiler wants to complain because it sees you’re doing something stupid, but it also sees that it’s not allowed to complain due to your pointer-cast, so it drops the error message into the bit-bucket. It’s like putting duct tape on the com

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.