LWN: Comments on "Some __nonstring__ turbulence" https://lwn.net/Articles/1018486/ This is a special feed containing comments posted to the individual LWN article titled "Some __nonstring__ turbulence". en-us Sat, 08 Nov 2025 16:20:05 +0000 Sat, 08 Nov 2025 16:20:05 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net GCC pre-releases and venerable traditions https://lwn.net/Articles/1022126/ https://lwn.net/Articles/1022126/ sammythesnake <div class="FormattedComment"> Debian uses a tilde for version numbers that should reliability sort before, rather than after, an upcoming version. You'll see this with the "backports" section (i.e. versions from testing adapted to be installed on the stable release of Debian)<br> <p> E.g. there's foo-1.8 in stable, foo-2.0~bp1 in backports, and foo-2.0 in testing. When the next stable release of Debian happens, foo-2.0 will be considered a "newer" version than foo-2.0~bp1 and installed preferentially.<br> <p> Typically, the last backports version is identical with the new stable version except for being compiled against (and declaring dependencies on) the older libraries available in stable.<br> <p> Conceptually, it's like having a patch version number of "-1" which naturally sorts earlier than a patch version of "0" (i.e. foo-2.0~bp1 sorts like 2 point 0 point -1 point (bp)1 &lt; 2 point 0 point 0)<br> <p> I like the semantics of this approach, but it does require that whatever is sorting version numbers understands what the tilde means and isn't really a widespread enough idiom for that be be something one can assume in general.<br> </div> Thu, 22 May 2025 15:25:37 +0000 No safeguards? https://lwn.net/Articles/1019892/ https://lwn.net/Articles/1019892/ Wol <div class="FormattedComment"> <span class="QuotedText">&gt; Now think about all the people who do not software full time and think: How hard could software be? If it were hard, it wouldn't be called "soft"ware :-)</span><br> <p> Job security? If software is hard, you have to leave it to the professionals? <br> <p> I've only once worked in a pure software environment - it drove me almost suicidal. Pretty much every job I've had has been a small DP team supporting end users. There's no reason why software should be hard. If you have a mixed team of professional end users who can program, professional programmers who can end-user, AND EASY-TO-USE SOFTWARE, then doing things "right" isn't hard. That's why I'm a Pickie!!!<br> <p> (And I don't call Excel, SQL, BQ/Oracle/etc easy to use.)<br> <p> Cheers,<br> Wol<br> </div> Fri, 02 May 2025 15:34:53 +0000 No safeguards? https://lwn.net/Articles/1019884/ https://lwn.net/Articles/1019884/ marcH <div class="FormattedComment"> <span class="QuotedText">&gt; does any programming education teach you anything about test coverage and trying to break your own code? Or version control, or code reviews, or CI, or any quality topic,... </span><br> <p> How could I forget the "ugliest" child of them all: build systems :-D<br> </div> Fri, 02 May 2025 14:56:18 +0000 No safeguards? https://lwn.net/Articles/1019881/ https://lwn.net/Articles/1019881/ marcH <div class="FormattedComment"> Like all people in a "privileged" work environment, I'm not sure you realize how ridiculously little testing some code gets before being submitted. Discussing "mutation testing" with the corresponding submitters is like trying to discuss literature with children learning to read. Please wait until they've reached middle school? In the mean time, "manually" point at a couple lines in their submission and ask them if any test fails when they break them. You might rarely ever interact with any such people so you can't notice but I can promise you there are some who never bother to try anything like that. Learning to do that does not require _any_ search which is already too much for people absolutely not interested in spending any time finding any bug with their code[*]. The very first ("baby") step is fixing that _mindset_ and that's already difficult enough. Don't scare these people with textbooks, at least not at first.<br> <p> I've used an education analogy which makes me wonder: does any programming education teach you anything about test coverage and trying to break your own code? Or version control, or code reviews, or CI, or any quality topic,... I don't remember any at all but it was a while ago. I learned it all on the job. But these were full time software jobs. Now think about all the people who do not software full time and think: How hard could software be? If it were hard, it wouldn't be called "soft"ware :-)<br> <p> [*] that's the job of the "validation team". Their precious time should be spent writing new bugs^H code.<br> </div> Fri, 02 May 2025 14:44:45 +0000 No safeguards? https://lwn.net/Articles/1019806/ https://lwn.net/Articles/1019806/ NYKevin <div class="FormattedComment"> It's not that easy. Saying "mutation testing" to a developer who has never heard of it is probably not the best way to evangelize mutation testing... but it *is* the best search term to find tooling that enables you to actually do it (without having to reinvent everything from scratch). So we're stuck using fancy ten dollar words for these things at least some of the time.<br> </div> Fri, 02 May 2025 07:53:37 +0000 No safeguards? https://lwn.net/Articles/1019388/ https://lwn.net/Articles/1019388/ pizza <div class="FormattedComment"> <span class="QuotedText">&gt;&gt; I'm in the MAINTAINERS file.</span><br> <span class="QuotedText">&gt;That explains it.</span><br> <p> Explains what, exactly?<br> <p> <p> </div> Wed, 30 Apr 2025 11:21:09 +0000 No safeguards? https://lwn.net/Articles/1019380/ https://lwn.net/Articles/1019380/ Avamander <div class="FormattedComment"> <span class="QuotedText">&gt; I'm in the MAINTAINERS file.</span><br> <p> That explains it.<br> </div> Wed, 30 Apr 2025 09:43:29 +0000 No safeguards? https://lwn.net/Articles/1019340/ https://lwn.net/Articles/1019340/ pizza <div class="FormattedComment"> <span class="QuotedText">&gt; I bet you're not the only one in such a difficult situation, maybe there are other people who can help?</span><br> <p> I'm afraid the difference between "can help" and "will help" is effectively insurmountable -- at least when there is no money involved.<br> <p> <p> <p> <p> </div> Tue, 29 Apr 2025 20:06:22 +0000 No safeguards? https://lwn.net/Articles/1019330/ https://lwn.net/Articles/1019330/ marcH <div class="FormattedComment"> I'm really sorry that have you been hurt by ISO 9000 in the past and that this tangent of mine acted as a "trigger" for you. But this was just a tangent, I know nothing about ISO 9000 specifically and there is not much I can do to help with your healing process. On the contrary, my key message was: baby steps, don't even use fancy words like "mutation" to avoid scaring people.<br> <p> I bet you're not the only one in such a difficult situation, maybe there are other people who can help?<br> <p> </div> Tue, 29 Apr 2025 16:11:09 +0000 No safeguards? https://lwn.net/Articles/1019329/ https://lwn.net/Articles/1019329/ marcH <div class="FormattedComment"> <span class="QuotedText">&gt; versus "I created a situation that resulted in a failure but the existing tests didn't catch it, and if you don't fix this coverage gap immediately you're clearly lying about everything and can't be trusted blablabla"</span><br> <p> Well beyond a strawman: it's elevated to an art form! :-)<br> <p> </div> Tue, 29 Apr 2025 16:01:25 +0000 Open source upstreams aren't suppliers https://lwn.net/Articles/1019323/ https://lwn.net/Articles/1019323/ farnz They're either an upstream offering you a project, or a downstream offering you a patch. They are not a supplier in either case, and expecting them to behave like a supplier is going to lead to problems and misunderstandings, precisely because that's the wrong sort of relationship to imagine. <p>Upstream and downstream also gets interesting because, unlike supplier and customer, it's one where the same entities dealing with the same project can change roles; Linus Torvalds is upstream of me in the Linux kernel fork he runs (and that we generally accept as the mainline), but if I chose to run my own Linux fork, Linus could choose to be downstream of me and submitting patches to me, or pulling patches from my upstream project into his downstream project. And, for added fun, Linus and I can swap roles - I can treat Linus as my upstream when I pull in 6.16, but then treat him as my downstream if he notices that I have a useful change that he'd like in his kernel. Tue, 29 Apr 2025 15:31:44 +0000 No safeguards? https://lwn.net/Articles/1019322/ https://lwn.net/Articles/1019322/ kleptog <div class="FormattedComment"> We solve this by having a "make quick-test" target which looks the the last commit and based on the directories of the files modified runs some specific subset of the tests. So if you're modifying the Makefile or some shared repo it's still going to take a while. But for the majority of patches you end up only running the tests for a single subsystem which reduces the turnaround time significantly.<br> <p> Sure, it occasionally happens that a patch does actually break a test in another subsystem that you didn't expect, but that's pretty uncommon.<br> <p> Like you, I wanted to automated this dependency detection, but a hand-maintained list gave all almost all the bang for very little buck.<br> </div> Tue, 29 Apr 2025 15:15:31 +0000 Open source upstreams aren't suppliers https://lwn.net/Articles/1019320/ https://lwn.net/Articles/1019320/ Wol <div class="FormattedComment"> <span class="QuotedText">&gt; In the end, an upstream is not a supplier; there's even a different word to describe the relationship, since you have supplier/customer relationships in business, and upstream/downstream relationships in open source. Expecting an upstream to act as a supplier is opening yourself up to a world of pain every time the upstream's priorities and yours don't coincide.</span><br> <p> I thought we were talking about a DOWNSTREAM SUPPLYING faulty patches.<br> <p> So we're blacklisting people who can't be arsed to supply properly working, tested code.<br> <p> I have to be careful here, as I've done exactly that, but I've done my best to provide stuff that works (in a language, Scheme, that I find very difficult to work with), and I just have to accept that if nobody else sees value in what I've done they won't take it on. But if I behaved "entitled" and expected somebody to finish the work for me, then they have every right not to want to do business with me.<br> <p> It all boils down, once again, to the "entitled" mentality a lot of people seem to have about other people doing work for "free" ...<br> <p> Cheers,<br> Wol<br> </div> Tue, 29 Apr 2025 15:12:12 +0000 Open source upstreams aren't suppliers https://lwn.net/Articles/1019314/ https://lwn.net/Articles/1019314/ farnz The question then becomes where you're going to go for open source software if you blacklist all upstreams that refuse to act as suppliers. You can, of course, pay Red Hat, SUSE, Canonical, CIQ or others to act as your supplier based on top of open source upstreams, but then you're not going straight to the person who writes the code. <p>In the end, an upstream is not a supplier; there's even a different word to describe the relationship, since you have supplier/customer relationships in business, and upstream/downstream relationships in open source. Expecting an upstream to act as a supplier is opening yourself up to a world of pain every time the upstream's priorities and yours don't coincide. Tue, 29 Apr 2025 14:50:25 +0000 No safeguards? https://lwn.net/Articles/1019309/ https://lwn.net/Articles/1019309/ pizza <div class="FormattedComment"> <span class="QuotedText">&gt; Clearly not:</span><br> <p> I've been part of the team dragging an organization through ISO9000 certification.<br> I've also worked for organizations in highly regulated spaces where ISO9000 was just the first of many, many steps.<br> <p> But hey, if you're all about that process, guess what? You can report the test coverage bug through official channels, it will be triaged and prioritized based on the documented process, and it it meets the actionable threshold (ie it's the supplier responsibility to fix, as opposed to "new work" which may itself require further negotiations) it will be added to the development backlog. Eventually, it gets handed to a developer, and has to be QA'd and signed off by whatever else the process requires, and _eventually_ will land in some some future release.<br> <p> So if you want that level of assurance and process from your suppliers? It's going to cost you... a _lot_. Not just in money, but time as well.<br> <p> What's that, you have no formal contract that specifies the deliverables, compensation, and processes for reporting problems, plus the SLA for responses? Then they're not your supplier, and you have precisely *zero* legal (or moral) right to demand anything from them. Enjoy the "AS IS, NO WARRANTY WHATSOEVER" terms of the software you didn't pay for.<br> </div> Tue, 29 Apr 2025 14:36:40 +0000 No safeguards? https://lwn.net/Articles/1019313/ https://lwn.net/Articles/1019313/ jezuch <div class="FormattedComment"> Bah, should've read the entire thread before answering :)<br> </div> Tue, 29 Apr 2025 14:32:10 +0000 No safeguards? https://lwn.net/Articles/1019311/ https://lwn.net/Articles/1019311/ jezuch <div class="FormattedComment"> I think it's called mutation testing?<br> </div> Tue, 29 Apr 2025 14:30:55 +0000 No safeguards? https://lwn.net/Articles/1019308/ https://lwn.net/Articles/1019308/ pizza <div class="FormattedComment"> <span class="QuotedText">&gt; I think you're missing the point that that person cannot be trusted. If you've got any sense, you're going to blacklist him as a supplier ... especially if you're paying him in credibility!</span><br> <p> How many times do I have to point out that this person is *NOT* your supplier? <br> <p> You're going to get better resuts when starting with "hey, your test coverage is missing something, here's a patch that fills the gap" versus "I created a situation that resulted in a failure but the existing tests didn't catch it, and if you don't fix this coverage gap immediately you're clearly lying about everything and can't be trusted blablabla"<br> <p> <p> </div> Tue, 29 Apr 2025 14:20:12 +0000 No safeguards? https://lwn.net/Articles/1019249/ https://lwn.net/Articles/1019249/ Wol <div class="FormattedComment"> <span class="QuotedText">&gt; But even if it's true, so what? That person is not your supplier [1].</span><br> <p> I think you're missing the point that that person cannot be trusted. If you've got any sense, you're going to blacklist him as a supplier ... especially if you're paying him in credibility!<br> <p> "Honesty is the best policy" - I do my best to test my code, but I still regularly get bitten by quirks of the language, things I've forgotten, etc etc. And I try and make sure that my "customers" know what is tested and what isn't. The fact that half the time they don't listen, and the other half they don't understand, isn't my problem. Well it is, I have to fix the mess, but that's another incentive for me to try and get it right.<br> <p> Cheers,<br> Wol<br> </div> Tue, 29 Apr 2025 08:29:24 +0000 No safeguards? https://lwn.net/Articles/1019247/ https://lwn.net/Articles/1019247/ marcH <div class="FormattedComment"> <span class="QuotedText">&gt; Seriously?</span><br> <p> Clearly not:<br> <p> <span class="QuotedText">&gt; If you want ISO9000 compliance from me...</span><br> <p> <p> </div> Tue, 29 Apr 2025 04:31:55 +0000 No safeguards? https://lwn.net/Articles/1019246/ https://lwn.net/Articles/1019246/ pizza <div class="FormattedComment"> <span class="QuotedText">&gt; Take a look at this very short section of [ISO9000]</span><br> <p> Seriously?<br> <p> If you want ISO9000 compliance from me, you had damn well better be paying me.<br> <p> If you're not, I repeat: I AM NOT YOUR SUPPLIER.<br> <p> <p> </div> Tue, 29 Apr 2025 03:02:58 +0000 No safeguards? https://lwn.net/Articles/1019243/ https://lwn.net/Articles/1019243/ marcH <div class="FormattedComment"> <span class="QuotedText">&gt; That's a nice sequence of what-ifs.</span><br> <p> This is indeed a pretty specific and hypothetical path that we followed... _together_. Until now?<br> <p> <span class="QuotedText">&gt; But even if it's true, so what?</span><br> <p> Then there are two possibilities:<br> <p> 1. The maintainer of that subsystem does not care and merges code anyway.<br> 2. He cares and does not merge.<br> <p> In _either_ case, everyone can draw very clear, evidence-based and useful conclusions about the quality of that subsystem.<br> <p> The most important thing in quality is not the quality level itself. That level does matter of course, but what is even more important is not being ignorant and having some mere idea of where quality stand. <br> <p> Take a look at this very short section<br> <a href="https://en.wikipedia.org/wiki/ISO_9000_family#ISO_9000_series_Quality_Management_Principles">https://en.wikipedia.org/wiki/ISO_9000_family#ISO_9000_se...</a><br> It's all about processes, evidence and transparency. It's not concerned about defining what's "good" or "bad" quality, it's more about having some metrics in the first place - which unfortunately cannot be taken for granted.<br> <p> When testing is "underrated" and mostly ignored in code reviews, that quality information is not even available, no one knows! Maybe the engineer who submits the code has been following some strict but private company QA process? Or maybe he just winged the whole thing due to unreasonable deadlines. Who knows - anyone with a bit of experience in this industry has already seen both. So, even a very basic "did you test this?" discussion already goes a long way. <br> <p> Quality information is critical and actionable: it lets a company that sells some actual Linux-based product decide whether they should rewrite the Bluetooth subsystem or implement their own sound daemon versus stress-testing the existing one and participating upstream. Just some random examples; this sort of decisions happens all the time because open-source is "not a supplier".<br> <p> Note an evidence-based, testing discussion is also (and in many cases: has been) very useful to reduce maintainer overload. FAIL | UNTESTED -&gt; NACK. Done! Next (assuming that subsystem is interested in landing in some products)<br> <p> <p> </div> Tue, 29 Apr 2025 01:17:38 +0000 No safeguards? https://lwn.net/Articles/1019244/ https://lwn.net/Articles/1019244/ Paf <div class="FormattedComment"> The merge process is “Linus hits a button on a git command”, how could it be gated on anything without a more complex infra?<br> </div> Tue, 29 Apr 2025 00:53:31 +0000 No safeguards? https://lwn.net/Articles/1019242/ https://lwn.net/Articles/1019242/ pizza <div class="FormattedComment"> <span class="QuotedText">&gt; If someone submitting changes is seriously asking someone ELSE to fix their _own_ lack of test coverage, right after being caught red-handed lying about said coverage, well now there is very simple, clear and compelling evidence that this person cannot be trusted with testing.</span><br> <p> That's a nice sequence of what-ifs. <br> <p> But even if it's true, so what? That person is not your supplier [1].<br> <p> [1] <a href="https://www.softwaremaxims.com/blog/not-a-supplier">https://www.softwaremaxims.com/blog/not-a-supplier</a><br> </div> Tue, 29 Apr 2025 00:34:05 +0000 No safeguards? https://lwn.net/Articles/1019241/ https://lwn.net/Articles/1019241/ marcH <div class="FormattedComment"> If someone submitting changes is seriously asking someone ELSE <br> to fix their _own_ lack of test coverage, right after being caught red-handed lying about said coverage, well now there is very simple, clear and compelling evidence that this person cannot be trusted with testing.<br> <p> That's pretty far from not wanting to perform "mutation testing" or some other fancy word that most people won't even bother googling.<br> </div> Tue, 29 Apr 2025 00:02:59 +0000 No safeguards? https://lwn.net/Articles/1019232/ https://lwn.net/Articles/1019232/ pizza <div class="FormattedComment"> <span class="QuotedText">&gt; On the other hand, if you tell them "Did you realize breaking this or that line passes the tests anyway?" after they proudly claimed to have tested their changes, then there is a small chance it will make some difference.</span><br> <p> ...or respond with "patches with improved tests welcome!"<br> <p> <p> </div> Mon, 28 Apr 2025 19:55:10 +0000 No safeguards? https://lwn.net/Articles/1019229/ https://lwn.net/Articles/1019229/ marcH <div class="FormattedComment"> <span class="QuotedText">&gt; &gt; The simplest and most underrated technique is: manually _test the tests_ by temporarily breaking the product code. I keep being amazed at how few developers do or even know that technique.</span><br> <p> <span class="QuotedText">&gt; As stated in another reply, this is mutation testing.</span><br> <p> Yes and no.<br> <p> If you ask a developer who is not interested in finding problems "Could you please perform some mutation testing?" then guess what will happen: nothing at all (Mutation what?)<br> <p> On the other hand, if you tell them "Did you realize breaking this or that line passes the tests anyway?" after they proudly claimed to have tested their changes, then there is a small chance it will make some difference.<br> <p> Who knows; the younger ones who don't think they know everything yet might even feel like they just tasted something useful and "upgrade" to more advanced and extensive mutation testing in the longer term.<br> <p> Baby steps!<br> <p> </div> Mon, 28 Apr 2025 19:16:40 +0000 No safeguards? https://lwn.net/Articles/1019216/ https://lwn.net/Articles/1019216/ mathstuf <div class="FormattedComment"> <span class="QuotedText">&gt; The simplest and most underrated technique is: manually _test the tests_ by temporarily breaking the product code. I keep being amazed at how few developers do or even know that technique.</span><br> <p> As stated in another reply, this is mutation testing. One of my ideas is to use code and mutation testing to discover "this code affects this test" relations so that one could take a diff and run just the tests that "care" about it. This would help with test turnaround time during patch review (while still doing full runs prior to merging). One of our bottlenecks in our regular CI is that testing always runs everything even for "obviously cannot be affected by the diff" changes. It'd be much nicer to cycle just the relevant tests to green before moving onto the full test suite.<br> </div> Mon, 28 Apr 2025 16:34:44 +0000 No safeguards? https://lwn.net/Articles/1019214/ https://lwn.net/Articles/1019214/ daroc <p> LWN covered <a href="https://lwn.net/Articles/995276/"> one such tool</a> for Rust code in October. I've tried it in some of my personal projects since then and found it somewhat useful for expanding my test suites. </p> Mon, 28 Apr 2025 14:49:08 +0000 Imagine: the future https://lwn.net/Articles/1019126/ https://lwn.net/Articles/1019126/ mathstuf <div class="FormattedComment"> And…? `strcat` is a function and not some operator, so it's not like NUL-terminated strings really "win" there either. IMO, removing direct writes via pointers to strings would be a further benefit.<br> </div> Mon, 28 Apr 2025 12:16:34 +0000 GCC pre-releases and venerable traditions https://lwn.net/Articles/1019124/ https://lwn.net/Articles/1019124/ mathstuf <div class="FormattedComment"> FWIW, I was answering "what else", not giving suggestions for GCC :) .<br> <p> In any case, I like it and GCC's more than the even/odd flipping that used to be way more prevalent. AFAIK, HDF5 is a holdout on that front, but I struggle to think of others I come across these days.<br> </div> Mon, 28 Apr 2025 12:10:56 +0000 Orders of magnitude and exhaustive testing https://lwn.net/Articles/1019088/ https://lwn.net/Articles/1019088/ farnz The combination of property testing and order of magnitude thinking can help you find your way here, if you weren't already thinking about it. <p>Property testing randomly generates a test case, and confirms that a property holds (like your "must round trip from <tt>f32</tt> to <tt>realistic::Real</tt> to <tt>f32</tt> correctly"); there's libraries that can help with this, but it's also reasonable to write your own property-based tester if the problem space doesn't benefit from <a href="https://propertesting.com/book_shrinking.html">shrinking test inputs</a>. Once you have a property tester, it's not hard to use it to find out how much of the input domain you can test in one second - you adjust the number of random inputs you generate until your test case takes about a second to run. <p>From there, you need to know that an hour is about three times 10<sup>3</sup> seconds, and a day is about 80% of 10<sup>5</sup> seconds, while your input space size is roughly 10<sup>number of bits * 3 / 10</sup>; a 32 bit space is thus about 10<sup>9.6</sup> items (which you can round to 10<sup>10</sup> - approximation is the name of the game here), and a 64 bit space is about 10<sup>19.2</sup> (which you can round to 10<sup>20</sup>). <p>You then put the two together to work out how long your test would take if you stopped randomly generating test cases, and instead just went exhaustive; if your property test can test around 10<sup>6</sup> items in a second, then a day's run will cover 10<sup>11</sup> possibilities. This is more than the number of possibilities in 32 bits, so you can exhaustively test the 32 bit space in a day. Similarly, if you can get your random tester to test around 10<sup>13</sup> possibilities in a second on the available hardware, you know that a day will cover about 10<sup>18</sup> tests, and so you need 10<sup>2</sup> (or 100) days to exhaustively test a 64 bit space (which, while slow, is fast enough that you might leave it running and pick up all the cases it finds for manual testing into the future, at least on significant releases). <p>And, of course, you can short-circuit this if, in your judgement, a single data item can be tested in few enough clock cycles; you know that 1 GHz is 10<sup>9</sup> clock cycles per second, so if you judge that your test takes under 1,000 clock cycles per item, that's 10<sup>6</sup> tests per second, which can exhaust a 32 bit space in a day. Sun, 27 Apr 2025 18:54:50 +0000 No safeguards? https://lwn.net/Articles/1019071/ https://lwn.net/Articles/1019071/ tialaramex <div class="FormattedComment"> I like all of what's mentioned about testing, but I think it's worth mentioning one radical option that people need to have in the back of their heads when thinking about tests: Exhaustive testing.<br> <p> 256 seems like lots to us, and so we instinctively don't want want to try all 256 possible inputs to a function which takes a single byte. But 256 is nothing to a machine, so exhaustive tests are an effective choice here and might catch bugs in weird cases you hadn't considered.<br> <p> Obviously you can't always do this, for a variety of reasons, and when you can it may be too slow and need to run overnight or something - but it's worth having the idea in your mind because when you can just try everything that's it, you're done, all inputs were tested.<br> <p> I was testing my impl TryFrom&lt;f32&gt; for realistic::Real and impl From&lt;Real&gt; for f32 to check that they round trip when non-NaN and finite. I quickly discovered a one epsilon problem for some values, not a big deal given the relatively low precision of 32-bit floats but good to know and worth fixing - however a million into the exhaustive testing it found huge deviations because my previous "I know what to test" testing hadn't hit upon some important cases and the exhaustive testing had stumbled onto these - we're talking an order of magnitude size error like oops 0.07 isn't 0.0067<br> </div> Sun, 27 Apr 2025 13:55:43 +0000 Imagine: the future https://lwn.net/Articles/1019067/ https://lwn.net/Articles/1019067/ wahern <div class="FormattedComment"> There were two competing proposals, Tom MacDonald's Variable Length Arrays (<a href="http://jclt.iecc.com/Jct13.pdf#page=67">http://jclt.iecc.com/Jct13.pdf#page=67</a>), and Ritchie's Variable-Size Arrays (<a href="http://jclt.iecc.com/Jct22.pdf#page=5">http://jclt.iecc.com/Jct22.pdf#page=5</a>). The committee eventually went with MacDonald's, apparently. Both proposals seemed to emphasize the utility for numerical computing a la Fortran, not for automatic bounds checking. Also, neither resolved the function parameter syntax problem--i.e. array parameter decay. In Ritchie's proposal, same as in MacDonald's, you were (syntactically) passed a pointer to an array, which required (syntactic) dereferencing. Ritchie's example prototype: foo(int (*a)[?][?]). MacDonald's (and VLAs since C99): foo(int n, int m, int (*a)[n][m]). In both cases sizeof (*a) worked as expected, but resolving at runtime.<br> <p> Notably, Ritchie's proposal lacked variable size automatic storage arrays. With the VLA proposal, you can declare arrays on the stack: int a[n][m];. In Ritchie's proposal you were required to use malloc (or alloca?): int (*a)[?][?] = (int (*)[n][m])<br> malloc(n * m * sizeof (int)));. I don't think this was an intrinsic limitation; I think Ritchie just objected to the ambiguity of how and when sizeof evaluated the integral expression(s) used in the type definition (i.e. n and m above). MacDonald's paper mentions that the compiler would have to cache the evaluated value so it reflected the value of the type at it's declaration; subsequently modifying n or m wouldn't change the result of sizeof. Except when using VLAs in parameters, or with variable length structures (part of the original proposal), this wasn't quite true (or true but irrelevant), something fat pointers avoids.<br> <p> It would have been better if we ended up with Ritchie's proposal. But I surmise (based on those papers alone) that MacDonald's won the day because 1) it was easier to implement--no ABI changes nor introduction of fat pointers into the compiler architecture; 2) GCC seemed to already have most of the implementation already, albeit with a slightly different syntax; 3) Ritchie gave short shrift to declaring automatic storage variable size arrays; 4) MacDonald was working at Cray so presumably was deemed to speak for pressing industry demands. #3 and #4 seem especially pivotal given everybody's preoccupation with numerical computing rather than bounds safety per se.<br> <p> </div> Sun, 27 Apr 2025 10:29:40 +0000 Attribute on type vs variable https://lwn.net/Articles/1019065/ https://lwn.net/Articles/1019065/ jwakely <div class="FormattedComment"> <span class="QuotedText">&gt;Seems what's really wanted here is the ability to use string literal syntax, but without an implicit trailing NUL, obviating the need to warn about it being dropped</span><br> <p> I agree that some special literal syntax to exclude the nul would be useful, but I think there's also value in marking the variable as "not a string". That could allow the compiler to warn it you pass it to strlen, strcpy etc.<br> <p> That might not be very relevant to the kernel but seems useful in general.<br> <p> But outside the kernel I would just use C++ which has better ways to do all this anyway (user-defined literals, string views, std::array, ...)<br> <p> <p> </div> Sun, 27 Apr 2025 09:34:43 +0000 Imagine: the future https://lwn.net/Articles/1019063/ https://lwn.net/Articles/1019063/ wahern <div class="FormattedComment"> In Ritchie's proposal[1] the fat pointers weren't just a 2-tuple like Rust's str. They were an N-tuple, according to the dimension of the array. char[][] would require a 3-word fat pointer, which is actually more space efficient compared to, say, an array of Rust str's, while preserving the ability to cast between fat and non-fat multidimensional arrays without copying. Also, technically, Rust therefore doesn't actually have fat pointers in the sense of Ritchie's proposal.<br> <p> I don't know why his approach was rejected. Perhaps it was the same reason Rust's fat-pointer-like data types aren't as general as what Ritchie proposed? But C99 ended up adopting the alternative approach he argued against--VLAs. And proposals for addressing some of the criticisms he pointed out seem poised for adoption, though they unfortunately missed the C23 window.<br> <p> [1] See <a href="https://web.archive.org/web/20151226050349/https://www.bell-labs.com/usr/dmr/www/vararray.pdf">https://web.archive.org/web/20151226050349/https://www.be...</a><br> </div> Sun, 27 Apr 2025 07:56:33 +0000 Attribute on type vs variable https://lwn.net/Articles/1019058/ https://lwn.net/Articles/1019058/ wahern <div class="FormattedComment"> <span class="QuotedText">&gt; The __nonstring__ attribute applies to variables, not types, so it must be used in every place where a char array is used without trailing NUL bytes. He would rather annotate the type, indicating that every instance of that type holds bytes rather than a character string, and avoid the need to mark rather larger numbers of variable declarations. But that is not how the attribute works, so the kernel will have to include __nonstring markers for every char array that is used in that way.</span><br> <p> I don't think it could work well as an attribute on the type. The relevant type is a char array, not just a char, nor (in this scenario) pointer-to-char. While you can typedef a char array, only to either an incomplete array type (typedef char foo[]) or an array of a specific size (typedef char foo[42]). I don't think there's a way to use the typedef while also being able to set the size at the variable declaration, as required by the example (cachefiles_charmap[64]). And you want to be able to define the size at the declaration, not the definition, in order to be able to use a string literal for initialization. You can use an initializer list ({ 'A', 'B', ...}), but that's not only more cumbersome, it entirely defeats the purpose as there would be no diagnostic to suppress in that case. You could in theory just set the attribute on the scalar typedef (type char foo) and make it work in the compiler, as Linus clearly had in mind, but it's ugly and arguably non-sensical--you're setting an attribute on a type that's only meaningful when the type is used derivatively. This kind of attribute exposes the gaps in C array semantics.<br> <p> Seems what's really wanted here is the ability to use string literal syntax, but without an implicit trailing NUL, obviating the need to warn about it being dropped. But that's not the feature GCC has. :( This problem is kind of par for the course for alot of C extensions, especially ones involving arrays--leaky abstractions predicated on internal compiler semantics and conspicuously highlighting gaps in C array semantics.<br> <p> </div> Sun, 27 Apr 2025 06:55:08 +0000 No safeguards? https://lwn.net/Articles/1019052/ https://lwn.net/Articles/1019052/ roc <div class="FormattedComment"> This is called mutation testing. There are a lot of existing tools for it, some of which are C-syntax-aware. Also there are mutation-testing tools that work by patching binary code.<br> </div> Sun, 27 Apr 2025 01:51:47 +0000 Fedora not stable distro. https://lwn.net/Articles/1019049/ https://lwn.net/Articles/1019049/ shemminger <div class="FormattedComment"> Agree, the point of being an upstream developer is to be a scout and clear the path.<br> It is much worse when some enterprise customer reports an issue when a new widget comes out.<br> <p> </div> Sun, 27 Apr 2025 00:08:02 +0000 No safeguards? https://lwn.net/Articles/1019048/ https://lwn.net/Articles/1019048/ gmaxwell <div class="FormattedComment"> I have a set of shell scripts that will go through source code and make varrious mutations one at a time such as change + to -, replace &amp;&amp; with ||, replace 0 with ~0, change 1 to 2 or 2 to 1, swaps &lt;, &gt;, and =, inserts negations, blanks a line entirely, etc. Then it attempts to compile the code with optimizations. If it compiles, the script checks the sha256sum of the resulting binary against all the hashes it's seen before and if it's a new hash it runs the tests. If the tests pass the source is saved off for my manual inspection later.<br> <p> The single point changes tend to not make errors which self cancel out, and usually if an error does cancel out or the change is in code that doesn't do anything the binary will not change. In code where tests have good condition/decision branch coverage most things this procedure catches are test omissions or bugs.<br> <p> This approach is super slow and kludgy, I've been repeatedly surprised and frustrated that no one has made a C-syntax aware tool to do similar testing without wasting tons of time on stuff that won't compile or won't make a difference (e.g. mutating comments.. though sometimes I've addressed this by first running the code through something that removes all the comments).<br> <p> But it's worked well enough for me and parsing C syntax is far enough away from the kind of programming I enjoy that I haven't bothered trying to close this gap myself.<br> <p> </div> Sun, 27 Apr 2025 00:03:52 +0000