6 ms·
You can do the same with a modren C compiler - the extern and auto mean the same and int is still the default type.
by netbsdusers 1y ago
You can do the same with a modren C compiler - the extern and auto mean the same and int is still the default type.
- tialaramex 1y agoIn C23, auto doesn't have a default type, if you write auto without a type then you get the C++ style "type deduction" instead. This is part of the trend (regretted by some WG14 members) of WG14 increasingly serving as a way to fix the core of C++ by instead mutating the C language it's ostensibly based on. You can think of deduction as crap type inference.
- deleted 1y ago[deleted]
- pjmlp 1y agoDesign by committee, the outcome is usually not what the people on the trenches would like to get.
- uecker 1y agoNobody in the trenches seemed to use old-style auto in the last decades. BTW: The right place to complain if you disagree would be the compiler vendors. In particular the Clang side pushes very much for keeping C and C++ aligned, because they have a shared C/C++ FE. So if you want something else, please file or comment on bugs in their bug tracker. Similar for other compilers.
- Y_Y 1y ago> Nobody in the trenches seemed to use old-style auto in the last decades. To the beat of my knowledge, there was no case where "auto" wasn't redundant. See e.g. https://stackoverflow.com/a/2192761 https://stackoverflow.com/a/2192761 This makes me feel better about repurposing it, but I still hate the shitty use it's been put to.
- pjmlp 1y agoIndeed, however many in the treches would like a more serious take on security, complaining has not served anything in the last 50 years until goverment agencies finally decided to step in.
- uecker 1y agoThis is again a problem compilers could have addressed, but didn't. Mostly because the users in the trenches did not care. Instead they flocked in droves to the compiler optimizing in the most aggressive way and rejecting everything costing performance. So I do not have the feeling that users were really pushing for safety. They are very good at complaining though.
- ndiddy 1y agoGCC and Clang support asan/ubsan, which lets you trade performance for nicer behavior related to memory access and undefined behavior. Whenever I do C development for a platform that supports asan/ubsan, I always develop and test with them enabled just because of how much debugging time they save.
- uecker 1y agoYes. Ubsan you should probably also turn on in production.
- pjmlp 1y agoIt is like democracy, election results not always reflect the needs of everyone, and some groups are more favored than others.
- jeltz 1y agoIsn't the original inclusion of the auto keyword more in line with what you expect from design by committee? Including a keyword which serves no purpose other than theretical completeness?
- pjmlp 1y agoI was talking more in general, not specific regarding auto. Actually I did use C compilers, with K&R C subset for home computers, where auto mattered. Naturally they are long gone, this was in the early 1990's.
- windward 1y agoIt doesn't matter. The people in the trenches don't update their standard versions.
- mhh__ 1y agoAn interesting secondary meaning of "design by committee", the reason why what you mention happens, is "design in committee". People can skip the usual lifecycle and feedback for an idea by presenting jumping directly to committee stage./
- saagarjha 1y agoPeople in the trenches seem pretty happy with what the committee designed here.