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.

“That is either genius, or a seriously diseased mind.” – Linus Torvalds

76 pointsby soohamover 5 years ago

3 comments

roelschroevenover 5 years ago
In that post Linus says something I don&#x27;t understand in that post:<p>&quot;... So with a constant, we have<p><pre><code> sizeof( 1 ? NULL : (int *) 1) </code></pre> and the rule is that if one of the sides of a ternary operation with pointers is NULL, the end result is the other type (int *).&quot;<p>Is Linus saying that the condition of the ternary operation doesn&#x27;t matter if one of the sides is NULL? That it then always evaluates to the other side? That&#x27;s not what happens when I try it. Or are there special rules when sizeof is applied?
评论 #20836954 未加载
rurbanover 5 years ago
I really need this for libc optimizations. So far it only worked in C++ mode or newer clang&#x27;s, but not in gcc.
msarnoffover 5 years ago
Isn&#x27;t this what GCC&#x27;s `__builtin_constant_p()` does?