TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A Guide to Undefined Behavior in C and C++ (2010)

79 pointsby GarethX2 months ago

6 comments

jasonthorsness2 months ago
This is an area the newer languages get right - I don’t think Rust or Go has any undefined behavior? I wish they would have some kind of super strict mode for C or C++ where compilation fails unless you somehow fix things at the call sites to tell the compiler the behavior you want explicitly.
评论 #43384226 未加载
评论 #43384111 未加载
评论 #43383993 未加载
评论 #43386197 未加载
评论 #43384295 未加载
hoseja2 months ago
Don't let people performatively horrified of undefined behaviour know about Gödel.
zombot2 months ago
The most horrifying aspect of UB is that it can affect your program without the instructions triggering it ever being executed. And many greenhorns don't know that or even believe it to be false. So the effects of Dunning-Kruger may be more severe in C(++) than in other languages.
评论 #43389026 未加载
guimplen2 months ago
The first example (signed integer overflow) is no longer valid in newer standards of C. Now it should use the two-complement semantics and no UB.
评论 #43384109 未加载
评论 #43394031 未加载
fsckboy2 months ago
my opinion as a very experienced C system programmer:<p>there must be better sources to guide people than a poorly written and infantilizing article from 15 years ago.
评论 #43384887 未加载
评论 #43383750 未加载
评论 #43384602 未加载
评论 #43384095 未加载
评论 #43386803 未加载
评论 #43386213 未加载
mwkaufma2 months ago
Despite the high frequency that alarmist &quot;formatting you HDD&quot; is cited in discussing UB, I&#x27;ve never seen it happen. Surely there exist real examples of catastrophic failures which could actually teach us something, beyond making a hyperbolic point.
评论 #43385450 未加载
评论 #43385551 未加载