alt.hn

6/3/2026 at 12:26:57 PM

Git Has a Variable Named false_but_the_compiler_does_not_know_it

https://blog.codingconfessions.com/p/false-but-the-compiler-does-not-know-it

by sohkamyung

6/3/2026 at 2:28:25 PM

> To answer that, we need to look at where this macro is actually used.

You could have just told us without that structure but that was exactly where an ad started. What a miraculous synchronicity!

by hyperhello

6/3/2026 at 4:42:47 PM

I always hate when authors waffle around instead of just getting to it.

Why couldn't:

> Today, in weird C code tricks, I want to show you a small example from Git’s source code.

> Recently, I was poking around the Git source when a directory name caught my eye, it was named “compiler-tricks”. I thought, “This is a promising name, let’s see what’s inside of it”.

> Inside this directory, there was a file called not-constant.c, and the whole file contained just this:

Have been:

> In the land of weird C code, there's an example in Git's not-constant.c:

The entire article is exhausting. So many "so why this" and "to understand this, x". Could have gotten the entire point across in perhaps 10% of the space.

by goodmythical

6/3/2026 at 5:17:44 PM

It's the televisionization of the Internet. You should imagine it as a guy walking down a beach as the camera follows him looking sincerely and speaking to alleviate your loneliness and then there will be a shampoo ad!

by hyperhello

6/3/2026 at 1:38:03 PM

The article stops short of actually telling why would anyone need NOT_CONSTANT

by lostmsu

6/3/2026 at 2:54:26 PM

Keep reading beyond the ad...

In short, git has a 'create_ref_symlink' function that is replaced with a macro to '-1' on some build configurations. This means that any code which is conditioned on the success of create_ref_symlink would trigger a compiler warning when built with -Wunreachable-code. NOT_CONSTANT supresses this warning by preventing the compiler from realizing the code is unreachable. It also prevents the compiler from eliminating the dead code, but presumably that has only a negligable impact.

by gizmo686