Two polls coming. I'm curious about the same question but from two different perspectives. When you are programming, *of these choices*, what is most important *to you*?
-
Näytä tämä ketju
-
Vastauksena käyttäjälle @lefticus
I feel that correctness as an option it's unfair. Of course we want our code to be correct. What good is beautiful or fast code if it doesn't do anything. More interesting poll is what is important AFTER correctness.
5 vastausta 0 uudelleentwiittausta 5 tykkäystä -
Vastauksena käyttäjille @rob_brink ja @lefticus
The first of the code virtues is that it works.
1 vastaus 0 uudelleentwiittausta 1 tykkäys -
Vastauksena käyttäjille @tottinge ja @rob_brink
Much code appears to work but on closer inspection does not actually.
1 vastaus 0 uudelleentwiittausta 1 tykkäys -
I'm not sure I understand this. Is it just that the programmer forgot to test corner cases or that the behavior is able to change over time somehow?
2 vastausta 0 uudelleentwiittausta 0 tykkäystä -
Vastauksena käyttäjille @rob_brink ja @tottinge
Code that contains undefined behavior will appear to work in some situations and fail in others. Example: it may rely on the debugger default initializing values, or it may rely on objects being eliminated by the optimizer, all accidentally.
1 vastaus 0 uudelleentwiittausta 0 tykkäystä -
Example: https://godbolt.org/z/CRYzBI Only an optimized build on GCC exposes the UB. Only an optimized build on GCC gives you the appropriate warning. All cases are UB. The code appears to work. It's subject to breaking with different versions of different compilers.
2 vastausta 0 uudelleentwiittausta 1 tykkäys -
That's kinda a strawman of a UB case. This (https://godbolt.org/z/3Dsj4L ) is also UB, but it happens all the time in code that has been running for years. If absolutely no UB is the only definition of "correct", there likely isn't a project outside of toys that are correct.
2 vastausta 0 uudelleentwiittausta 0 tykkäystä -
Accessing an object after its lifetime has ended is in no way a strawman. You could argue it's slideware and over simplified, but it's the class of bug people deal with every day. If the memory has not yet been reused, it will appear to work.
2 vastausta 0 uudelleentwiittausta 1 tykkäys -
For the purposes of arguing whether a programmer/company desires correctness (no UB), it's very strawman. Most companies would desire avoiding your example, but would be perfectly fine with mine.
2 vastausta 0 uudelleentwiittausta 0 tykkäystä
If it's *all* UB vs perf, perf wins IMO. If you allow UB that I have tested on all hardware I will deploy on and it does the desired behavior, then correctness wins.
Lataaminen näyttää kestävän hetken.
Twitter saattaa olla ruuhkautunut tai ongelma on muuten hetkellinen. Yritä uudelleen tai käy Twitterin tilasivulla saadaksesi lisätietoja.