Lemmy 1095
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
abhi9u@lemmy.world to Technology@lemmy.worldEnglish · 18 hours ago

Why Git Has a Variable Named false_but_the_compiler_does_not_know_it_

blog.codingconfessions.com

external-link
message-square
7
fedilink
54
external-link

Why Git Has a Variable Named false_but_the_compiler_does_not_know_it_

blog.codingconfessions.com

abhi9u@lemmy.world to Technology@lemmy.worldEnglish · 18 hours ago
message-square
7
fedilink
A small C trick that keeps Clang from flagging valid code as unreachable
alert-triangle
You must log in or register to comment.
  • ProfessorScience@lemmy.world
    link
    fedilink
    English
    arrow-up
    12
    ·
    16 hours ago

    Another option is to disable the warning locally […] But this is compiler-specific and noisy. It also does not explain the real issue to anyone reading the code.

    I don’t understand this logic. Surely disabling the warning is directly explaining the actual issue, that the code emits a false positive warning for specific compilers and conditions? That the false_but_compiler_does_not_know_it_ thing is apparently the better way to convey what’s going on seems kind of ridiculous.

    • QuizzaciousOtter@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      15
      ·
      14 hours ago

      You could say that the current way is so unclear that the guy had to write a 2 thousand word essay to explain it.

    • UnrepentantAlgebra@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      11 hours ago

      My thought was that they may have to disable it differently for each compiler which might not be pretty, but yeah seems much easier to just do that as needed than to bend over backwards to look clever AND introduce unnecessary runtime effects at the same time.

    • Venator@lemmy.nz
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      14 hours ago

      My guess would be they didn’t like how verbose it was to supress the warning, or maybe they have a coding standard not to suppress warnings, and this was a workaround for that 😅

      • Venator@lemmy.nz
        link
        fedilink
        English
        arrow-up
        3
        ·
        edit-2
        13 hours ago

        actually not sure, as they do use #pragma GCC diagnostic ignored in a couple of places :

        https://github.com/git/git/blob/8d96f09e9245ddf80c1981476fcbac8c4bb4125f/compat/win32/headless.c#L14

        https://github.com/git/git/blob/8d96f09e9245ddf80c1981476fcbac8c4bb4125f/compat/regex/regex.c#L20

        but apparently that disables it for everything after that line in the file though:

        https://stackoverflow.com/questions/48426484/concise-way-to-disable-specific-warning-instances-in-clang#comment83878587_48426846

        I think the second answer on that stackoverflow post might be better than false_but_the_compiler_does_not_know_it_ though…

  • ジン@quokk.au
    link
    fedilink
    English
    arrow-up
    9
    arrow-down
    1
    ·
    18 hours ago

    I disagree on the naming of ‘compiler-tricks’. Some of us are complete idiots and prefer the compiler trick US

    ​(​N​o​t​t​h​e​o​t​h​e​​r​w​a​y​a​r​o​u​n​d​.​)

  • sun_is_ra@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    5
    ·
    18 hours ago

    Good read!

    A small UI issue: the screenshot appear in darkmode but I could find how to trigger the dark mode in the website.

Technology@lemmy.world

technology@lemmy.world

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !technology@lemmy.world

This is a most excellent place for technology news and articles.


Our Rules


  1. Follow the lemmy.world rules.
  2. Only tech related news or articles.
  3. Be excellent to each other!
  4. Mod approved content bots can post up to 10 articles per day.
  5. Threads asking for personal tech support may be deleted.
  6. Politics threads may be removed.
  7. No memes allowed as posts, OK to post as comments.
  8. Only approved bots from the list below, this includes using AI responses and summaries. To ask if your bot can be added please contact a mod.
  9. Check for duplicates before posting, duplicates may be removed
  10. Accounts 7 days and younger will have their posts automatically removed.

Approved Bots


  • @L4s@lemmy.world
  • @autotldr@lemmings.world
  • @PipedLinkBot@feddit.rocks
  • @wikibot@lemmy.world
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 3.79K users / day
  • 8.27K users / week
  • 8.34K users / month
  • 8.37K users / 6 months
  • 2 local subscribers
  • 85.6K subscribers
  • 432 Posts
  • 6.65K Comments
  • Modlog
  • mods:
  • L3s@lemmy.world
    cake
  • enu@lemmy.world
  • Technopagan@lemmy.world
  • L4sBot@lemmy.world
  • L3s@hackingne.ws
  • BE: 0.19.5
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org