Confessions of a Code Addict
Read post

Why Git Has a Variable Named false_but_the_compiler_does_not_know_it

Git's source code contains a peculiarly named global variable `false_but_the_compiler_does_not_know_it_`, always initialized to 0 but never declared `const` and defined in a separate translation unit. This prevents Clang's `-Wunreachable-code` warning from firing on code that is only unreachable in certain build configurations (e.g., when `NO_SYMLINK_HEAD` is defined and `create_ref_symlink` becomes a constant `-1`). The `NOT_CONSTANT` macro wraps expressions with this variable via logical OR, making the compiler unable to prove the condition is always false at compile time. Alternative approaches like `#ifdef` guards, `#pragma` suppression, `volatile`, or a stub function are discussed and compared. The post also explores whether link-time optimization (LTO) eliminates the dead branch — it does, giving Git both warning suppression during normal builds and dead-code elimination with LTO enabled.

    #c#git#compiler-optimization
Jun 03•11m read time•From blog.codingconfessions.com
Post cover image
Table of contents
Where Git Uses This TrickWhy Git Added This MacroCould This Be Done Differently?Does the Linker Remove This Branch?
17.3K Impressions2 Comments
Confessions of a Code Addict's image
Confessions of a Code Addict

Code Confessions is a platform or blog where developers share their experiences, challenges, and ins...

26 Followers

•

341 Upvotes

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard