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.

Dennis Ritchie on alias analysis in C (1988)

62 pointsby r4umabout 4 years ago

5 comments

CyberRabbiabout 4 years ago
I had a hard time following Ritchie’s argument. I guess I’m missing a lot from the proposals he’s critiquing. One part stood out that was not clear:<p>&gt; memcpy(noalias void *s1, const noalias void *s2, size_t n);<p>&gt; what information can one glean from it? Some committee members apparently believe that it conveys either to the reader or to the compiler that the routine is safe, provided that the strings do not overlap. They are mistaken.<p>I don’t follow. It seems that noalias exactly means that the two arrays can never point to the same memory, thus they do not overlap. So why would it be wrong to assume that memcpy() with noalias arguments is safe if called with non-overlapping memory?<p>————<p>Separately I agree with him that “noalias” unlike “const” is not a property of the object being pointed to but rather a property of the access being done. It creates an inconsistency where “char * noalias” makes sense but “char noalias” doesn’t. Perhaps he would have supported a “noalias dereference” operator or compiler built-in instead.
评论 #26524883 未加载
评论 #26524709 未加载
doogliusabout 4 years ago
blogspam for <a href="https:&#x2F;&#x2F;groups.google.com&#x2F;g&#x2F;comp.lang.c&#x2F;c&#x2F;K0Cz2s9il3E&#x2F;m&#x2F;YDyo_xaRG5kJ" rel="nofollow">https:&#x2F;&#x2F;groups.google.com&#x2F;g&#x2F;comp.lang.c&#x2F;c&#x2F;K0Cz2s9il3E&#x2F;m&#x2F;YDyo...</a>
评论 #26525385 未加载
评论 #26524486 未加载
pjmlpabout 4 years ago
Then 10 years later <i>restrict</i> was born with many of the same caveats that Dennis Ritchie refers to <i>noalias</i>.<p>A good example of when language authors no longer control its direction, rather the standards body.
评论 #26525692 未加载
kpsabout 4 years ago
“a license for the compiler to undertake aggressive optimizations that are completely legal by the committee&#x27;s rules, but make hash of apparently safe programs”<p>That phrase, describing ‘noalias’, proves that nobody at the time realized or intended what “undefined behavior” would turn out to mean.
xiphias2about 4 years ago
I think Dennis would love what Rust provides, it took just 45 years to fix noalias with a new language.
评论 #26524901 未加载