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.

Clang will more aggressively use undefined behavior on pointer addition overflow

5 pointsby mafuyabout 1 month ago

2 comments

hagreetabout 1 month ago
Can somebody explain what the optimizations are that this enables?<p>Of course you can optimize away the checks but that doesn&#x27;t count in my world because people put in these checks to make sure there is no overflow and optimizing them away is just wrong.<p>But I am sure there are other interesting optimizations that this allows and since I am generally against UB I am curious what those are.
mafuyabout 1 month ago
&gt; Clang will now more aggressively use undefined behavior on pointer addition overflow for optimization purposes. For example, a check like ptr + unsigned_offset &lt; ptr will now optimize to false, because ptr + unsigned_offset will cause undefined behavior if it overflows (or advances past the end of the object).
评论 #43703485 未加载