▲ 10 ▼ References vs Pointers (slicker.me) submitted 7 months ago by monica_b1998@lemmy.world to c/cpp@programming.dev 2 comments fedilink hide all child comments
[+] username_1@programming.dev 4 points 6 months ago (1 child) [deleted] permalink fedilink source hideshow 1 child comment replies: [–] scratchee@feddit.uk 1 point 6 months ago Yeah. References feel like they were originally made to be safer but any safety the could have provided got sacrificed to the compiler for a little more speed, leaving them more dangerous than pointers with the illusion of safety. That said, compilers are starting to get support for more hardening options now that c/c++ has to care about memory safety, I imagine this might be partially covered by that eventually (eg crash when assigning null to a reference, there's realistically no saving dangling references though) permalink fedilink source parent
[–] scratchee@feddit.uk 1 point 6 months ago Yeah. References feel like they were originally made to be safer but any safety the could have provided got sacrificed to the compiler for a little more speed, leaving them more dangerous than pointers with the illusion of safety. That said, compilers are starting to get support for more hardening options now that c/c++ has to care about memory safety, I imagine this might be partially covered by that eventually (eg crash when assigning null to a reference, there's realistically no saving dangling references though) permalink fedilink source parent