News for hackers. Stuff that matters.
Re:New C features in GCC 13 by flohofwoe on Thursday May 04, 2023 @10:16AM (#35815696)
Many things that C++ added on top of C aren't actually improvements (I guess the most charitable thing that can be said about C++ is that it identifies and weeds out all the stupid ideas before they can make it into C).
Re:New C features in GCC 13 by pjmlp on Thursday May 04, 2023 @01:57PM (#35819520)
At least WG21 actually acknowledges solving security issues and UB problems are a real problem that needs to be sorted out.

Meanwhile, WG14, "not our problem ".

Re:New C features in GCC 13 by shrimp_emoji on Thursday May 04, 2023 @08:12PM (#35823823)
Trying to figure out whether it's well-defined to compare two pointers to different objects in memory...

...By reading the C++ standard: "it's well-defined"

...By reading the C standard: *self-referencing Zalgo text quoted by dozens of StackOverflow thread debates where no completely confident conclusion is ever reached, although 3/4 people way smarter than you think it's well-defined and blame observations to the contrary on compiler bugs which they've reported to all the major compiler maintainers with varying reception from said maintainers as to whether they agree that those are actually bugs, forcing you, at the end of the day, to realize that you should really be writing your compiler's C, not aspiring to a universal, platonic ideal of C*

Re:New C features in GCC 13 by uecker on Saturday May 06, 2023 @10:02AM (#35841485)
Why? I do not find the wording in the C standard less clear than the C++ wording (where the result is unspecified for unrelated pointers).
Re:New C features in GCC 13 by ho_schi on Thursday May 04, 2023 @02:54PM (#35820367)
A usual programmer doesn’t need most features of C++ but there are many important:

Generic-programming with templates, a usable std::string, smart-pointers, references, the howl standard-library (streams, file access, containers, threads).

The controversial ones seem to be exceptions and classes. Exceptions affect programming flow, exception safety is very hard and the runtime costs are an issue depending on the environment. Class and inheritance are complicated feature, operator overloading is one of the best stuff I’ve seen. But I can understand why many programmers don’t want handle all the special rules involving classes.

Re:New C features in GCC 13 by flohofwoe on Friday May 05, 2023 @03:14AM (#35826238)
This would add a lot of complexity into the C compiler and stdlib, and C would just end up as another C++. IMHO it is still important that a C compiler and stdlib can be written in reasonable time by an individual or small team.

And just one example (because it's one of my favourite topics where the C++ stdlib really failed):

std::string as a standard string type has so many (performance) problems that it is borderline useless. You can't simply use it anywhere without being very aware of the memory management implications (when and where does memory allocation and freeing happen - and std::string does its best to obscure such important details), and this isn't just an esoteric niche problem: https://groups.google.com/a/chromium.org/g/chromium-dev/c/EU...

Re:New C features in GCC 13 by nly on Friday May 05, 2023 @03:30AM (#35826318)
Classes, which have constructors and destructors, simplify code immensely..so do copy and move constructors and operators.