Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Logical AND with false...

Logical AND with false...

Scheduled Pinned Locked Moved The Weird and The Wonderful
c++
9 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Albert Holguin
    wrote on last edited by
    #1

    Didn't notice this little piece of code and it was making me think some sections worked completely different than they actually do.

    //C++
    if(m_Config.m_isContinuous && false){ //<- should have probably payed closer attention to that...
    //A whole bunch of code that I thought was getting executed
    }
    else{
    //What's actually getting executed
    }

    Guess that was left like that for lack of time to clean up or something... but it shure led me astray... :doh:

    Z P B E 4 Replies Last reply
    0
    • A Albert Holguin

      Didn't notice this little piece of code and it was making me think some sections worked completely different than they actually do.

      //C++
      if(m_Config.m_isContinuous && false){ //<- should have probably payed closer attention to that...
      //A whole bunch of code that I thought was getting executed
      }
      else{
      //What's actually getting executed
      }

      Guess that was left like that for lack of time to clean up or something... but it shure led me astray... :doh:

      Z Offline
      Z Offline
      ZurdoDev
      wrote on last edited by
      #2

      Faked left and went right.

      1 Reply Last reply
      0
      • A Albert Holguin

        Didn't notice this little piece of code and it was making me think some sections worked completely different than they actually do.

        //C++
        if(m_Config.m_isContinuous && false){ //<- should have probably payed closer attention to that...
        //A whole bunch of code that I thought was getting executed
        }
        else{
        //What's actually getting executed
        }

        Guess that was left like that for lack of time to clean up or something... but it shure led me astray... :doh:

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        That's sort of a way to (temporarily) comment-out the then-section for testing. It probably shouldn't have made it to production.

        A B C 3 Replies Last reply
        0
        • P PIEBALDconsult

          That's sort of a way to (temporarily) comment-out the then-section for testing. It probably shouldn't have made it to production.

          A Offline
          A Offline
          Albert Holguin
          wrote on last edited by
          #4

          Like Ryan said above... it totally faked me out... :)

          1 Reply Last reply
          0
          • P PIEBALDconsult

            That's sort of a way to (temporarily) comment-out the then-section for testing. It probably shouldn't have made it to production.

            B Offline
            B Offline
            BobJanova
            wrote on last edited by
            #5

            Yeah, I've been known to do this at times, but I'd hope I'd never manage to check one in to source control!

            1 Reply Last reply
            0
            • A Albert Holguin

              Didn't notice this little piece of code and it was making me think some sections worked completely different than they actually do.

              //C++
              if(m_Config.m_isContinuous && false){ //<- should have probably payed closer attention to that...
              //A whole bunch of code that I thought was getting executed
              }
              else{
              //What's actually getting executed
              }

              Guess that was left like that for lack of time to clean up or something... but it shure led me astray... :doh:

              B Offline
              B Offline
              BillW33
              wrote on last edited by
              #6

              Yeah, things like that have a nasty habit of sneaking in to check-ins then making it to production code. :sigh:

              Just because the code works, it doesn't mean that it is good code.

              1 Reply Last reply
              0
              • A Albert Holguin

                Didn't notice this little piece of code and it was making me think some sections worked completely different than they actually do.

                //C++
                if(m_Config.m_isContinuous && false){ //<- should have probably payed closer attention to that...
                //A whole bunch of code that I thought was getting executed
                }
                else{
                //What's actually getting executed
                }

                Guess that was left like that for lack of time to clean up or something... but it shure led me astray... :doh:

                E Offline
                E Offline
                englebart
                wrote on last edited by
                #7

                My (latest) compiler has a "dead code" checker. We currently have "Dead code (e.g. 'if (false)')" set as a Warning, but I would like to promote this to an Error. I like to say that the Compiler is a programmer's best friend, just make sure you don't put blinders on it or it can't help you. Personal Pet Peeve: initializing variables to 0 or null when you can safely initialize a few lines later.

                A 1 Reply Last reply
                0
                • P PIEBALDconsult

                  That's sort of a way to (temporarily) comment-out the then-section for testing. It probably shouldn't have made it to production.

                  C Offline
                  C Offline
                  cpkilekofp
                  wrote on last edited by
                  #8

                  PIEBALDconsult wrote:

                  That's sort of a way to (temporarily) comment-out the then-section for testing. It probably shouldn't have made it to production.

                  It might actually be intended to stay in there until the developer's sure that the previous condition won't ever be used again...or the logic within the condition, which may be useful in a modified condition but might be difficult to remember. Sometimes it's easier to do that when you think your boss/customer/vendor has lost their mind than to trust that you'll remember exactly out of which source version you chopped it if you need it back NOW.

                  1 Reply Last reply
                  0
                  • E englebart

                    My (latest) compiler has a "dead code" checker. We currently have "Dead code (e.g. 'if (false)')" set as a Warning, but I would like to promote this to an Error. I like to say that the Compiler is a programmer's best friend, just make sure you don't put blinders on it or it can't help you. Personal Pet Peeve: initializing variables to 0 or null when you can safely initialize a few lines later.

                    A Offline
                    A Offline
                    Albert Holguin
                    wrote on last edited by
                    #9

                    englebart wrote:

                    Personal Pet Peeve: initializing variables to 0 or null when you can safely initialize a few lines later.

                    I'm sure somebody else' pet peeve is... "wait to initialize variable when you could've just done it with the declaration". Most C programmers do it that way...

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups