Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
pif
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
24 ms
·
301.
▲
by
pif
2y ago
Just to be clear, I don't dislike this post for showing practical examples of UB. I'm just afraid that readers could take the wrong path and reason "This compiler does so-and-so, now I know how to better protect my current co
302.
▲
by
pif
2y ago
> it was never portable Thank you for pointing this out.
303.
▲
by
pif
2y ago
> Our society thinks it is normal to have a creative work evaluated by accounting, but never the reverse. It is normal because it makes sense: people can spend the money as they wish, but the same cannot be stated for creativity.
304.
▲
by
pif
2y ago
> I don't think any programmer puts UB on purpose into the code I agree with you. But the problem is not people putting UB in their code, either on purpose or by mistake: we all do that, every day! The problem is people trying to de
305.
▲
by
pif
2y ago
Very well put! I'll just add that the third option is usually not considered viable because the main point of using C/C++ is for performance, thus people writing code want their compiler to optimize it as much as possible.
306.
▲
by
pif
2y ago
If the compiler threw it away, then the check was ill formed or just arrived too late.
307.
▲
by
pif
2y ago
> I don't see how it's wrong to use an if statement to check that nobody's passing in a zero to your function that later does division using that variable. Indeed, it isn't. The check becomes useless if it happens af
308.
▲
by
pif
2y ago
> things that people reasonably can assume would work but are UB anyway (signed integer overflow.) No, they cannot. You don't have the right to make any assumption about integer overflow in C. Most of the whining about UB is from pe
309.
▲
by
pif
2y ago
> treating UB as something you'll see frequently in your career Sure it is! I'm not talking about skills: everybody writes UB, at any time. I'm talking about attitude: when you see UB, you must strive to remove it, not to
310.
▲
by
pif
2y ago
> Given that reality, knowing what your compiler will do with UB ... The more you refuse to accept undefined behaviour, the more it will hurt when it will bite you! Stop turning around the problem and fix your code.
311.
▲
by
pif
2y ago
You'd expect them to have learnt the lesson with Internet Explorer but, as someone said, there is no way a man will understand something when his salary depends on him not understanding it!
312.
▲
by
pif
2y ago
This post has no point. Developers must avoid UB in their code, at all costs. Wondering what a specific compiler will do with your UB code is useless: as soon as you realise you have UB, go and fix it!
313.
▲
by
pif
2y ago
Any normality that is not backed by violence is respectable.
314.
▲
by
pif
2y ago
This looks to me as the idiocy of the pronouns, on steroids. They both are based on the wrong assumption that people have to ask your opinion before contacting you, while communication has always been based on shared standards. Normality ex
315.
▲
by
pif
2y ago
The discriminant is the following question: what if everybody behaved like me?
316.
▲
by
pif
2y ago
I can't wait for the Australian border to patrol the oceans in order to block this new "microorganism that could pose a serious risk to their ecosystem and blah blah blah..."
317.
▲
by
pif
2y ago
> when you actually need good performance for something that doesn't scale so well horizontally Truth is, you don't have the right to need fast cores any more. Those times are over, when you could write poor code and buy a more
318.
▲
by
pif
2y ago
> chinese ships would be stuck in drydock because they needed repairs or fuel and no locals would sell to them. Why do locals refuse business with them?
319.
▲
by
pif
2y ago
> Somehow, instead of "undefined behaviour" (using your definition) generating a compile time error, I'm sorry, but this sentence shows how little you understand about undefined behaviour. Undefined behaviour cannot genera
320.
▲
by
pif
2y ago
> Poor choices during development reveal themselves in many ways: ... All the examples you provided miss the point. Revenues are the point; all the rest is ancillary at best.
321.
▲
by
pif
2y ago
How many times will we have to discover, again and again, that Mercator projection is really the worst possible map, apart from all the others?
322.
▲
by
pif
2y ago
> the key to keep things in order is to remove things As soon as you are ready to give up the income for those things you want to trim, please go on!
323.
▲
by
pif
2y ago
I agree with you. Too many of us developers tend to forget that the customer only looks at the features. Clean code, unit tests, rigorous processes... they are only as valuable as the rate of features they make possible. Complexity and tech
324.
▲
by
pif
2y ago
> The old C compilers did not do that, ever, because K&R's "behaviour is undefined" did not give that sort of licence. This extrapolation of yours is not warranted! The first compilers were simpler, and optimizations c
325.
▲
by
pif
2y ago
A utopic solution would be to learn, at last, how to have a thriving economy without increasing megalopolis. Housing prices are unaffordable in big cities, while abandoned properties are rotting in the countryside everywhere. It's ti
326.
▲
by
pif
2y ago
> Using just assembly is not realistic. And using C as fully deterministic is idiotic, considering the effort that went into specifying in great details everything that is NOT deterministic. > I'd love C-like language which compi
327.
▲
by
pif
2y ago
> In K&C Undefined Behaviour meant "you get what the hardware gives you". No, what you are talking about is "implementation-defined". Out of all trades, programmers should know better than everybody else to code a
328.
▲
by
pif
2y ago
> I want behavior matching my architecture. Then use assembly. C is meant to abstract CPU architecture away.
329.
▲
by
pif
2y ago
You can define such a struct yourself. You do not need to modify the language.
330.
▲
by
pif
2y ago
What has humankind lost with those pages vanishing?
More ›