Quotes of the week
Currently, given a pointer "p", C allows p->a but not p.a. There is a proposal from C++ that is being considered for C.— Paul McKenneyDo we care?
After buying a new WTF'o'meter -- reading about this proposal definitely shattered the old one -- I'm with everybody else so far, this will not make C better, and if it ever were to pass, we should ensure the kernel does not use it.— Peter Zijlstra
Posted Jan 16, 2025 18:58 UTC (Thu)
by ncultra (✭ supporter ✭, #121511)
[Link] (1 responses)
Posted Jan 16, 2025 19:06 UTC (Thu)
by adobriyan (subscriber, #30858)
[Link]
Posted Feb 3, 2025 21:01 UTC (Mon)
by Spudd86 (guest, #51683)
[Link] (1 responses)
C++ on the other hand because it lets you overload things so that you might have an object where you could use both operators on it and do different things allowing one in place of the other seems insane.
Posted Feb 3, 2025 22:28 UTC (Mon)
by excors (subscriber, #95769)
[Link]
In the other languages mentioned in the proposal, a null dereference will give you an exception, which is just a bug. In C/C++ it's a security vulnerability, so it's pretty important to be aware of your pointer dereferencing.
Also it's a bad idea in C++ because smart pointers use `->` to access members of the pointed-at object and `.` to access members of the smart pointer itself. The proposal only changes the syntax for dereferencing raw pointers, so they would no longer match smart pointers, increasing confusion; and modern C++ should almost always be using smart pointers or references instead of raw pointers, to make ownership and lifetimes clearer, so even the proposal's hypothetical benefits wouldn't apply.
Anyway, judging by https://github.com/cplusplus/papers/issues/868 there's zero support for the idea so there's no need to worry about it.
Mayhem would ensue
Mayhem would ensue
C++ seems like the language that shouldn't have this.
C++ seems like the language that shouldn't have this.