> There are a shocking number of ways to accidentally create nondeterministic output when doing C/C++ development. One of the easiest is to use the builtin __DATE__ and __TIME__ macros to stamp a build with the time the compiler was executed at:
Am I missing something here? Yes, if you use a feature that intentionally inserts the build time and date into the code, the every build is going to be different. That's the whole point of these macros. It's a feature. If you don't want that behavior, don't use that feature.
It's meant to be a trivial counterexample. Like saying "-1" to the claim "there's no number smaller than 0" to someone who's not familiar with math, the author is saying "build-dependent macros" to the claim "compilers are deterministic" to someone who might not be familiar with compilers.
A trivial counterexample to what? The antecedent of "one of the easiest" was "ways to accidentally create nondeterministic output." One even the most charitable reading I can muster that still seems to me to presume some pretty abject stupidity.
A trivial counter example to the intuition one might have that compilers likely produce deterministic output. It’s directly responsive to the exchange between Aoi and Numa above, wherein Aoi expresses exactly that intuition. Of course, those are characters playing out a question less familiar readers might ask. Presumably the intent is to make this content accessible to a wider audience, using an obvious example to introduce the concept without requiring much background knowledge.
I think the intentional part is that you want to print the date and time something's been compiled, and the accidental part is that you suddenly made your build non-reproducible.
But usually the realization follows the initial intent by several weeks, if not months! Your comment shines as the embodiment of hindsight is 20/20.
> the accidental part is that you suddenly made your build non-reproducible
But that's exactly what I don't get. How can that be considered "accidental"? How can any thinking person not realize that putting the build time into the compiled image will make every build different because, you know, different builds happen at different times? Has software engineering really been dumbed down so much that this is not immediately obvious? It feels like a mechanic doing an oil change and being surprised by having all the oil drain out if they neglect to put the drain plug back in.
With you on this especially because somebody I know asked me to help change their oil and they hadn't even considered there being waste oil to dispose of
The engineer who wants the build to be reproducible and the engineer who wants to have the build time in the compiled binary may not be the same person.
Sure, but that is a completely different issue. People have mutually-conflicting goals on occasion. That is a Thing That Happens, but it is a very different phenomenon than being surprised by the obvious fact that putting a time stamp on your build makes that build non-reproducible.
Am I missing something here? Yes, if you use a feature that intentionally inserts the build time and date into the code, the every build is going to be different. That's the whole point of these macros. It's a feature. If you don't want that behavior, don't use that feature.