Illogical Logic Flow

« Return to Article
  • Drew 2009-06-01 09:02
    DO NOT REMOVE THIS COMMENT!
    The Daily WTF is skipping the Real WTF without it.
    Very weird.
  • sponk 2009-06-01 09:03
    That's a bit of a mild wtf. Someone isn't very good at programming. Oh no.
    At least they tried to figure out and fix whatever was going wrong, even if they didn't understand it.
  • jammy 2009-06-01 09:04
    Maybe it was because of... things.
  • Dinnerbone 2009-06-01 09:06
    Drew:
    DO NOT REMOVE THIS COMMENT!
    The Daily WTF is skipping the Real WTF without it.
    Very weird.


    '*******************************************************
    '***** DO NOT REMOVE THE APOSTROPHE AND STARS *****
    '***** Program will not compile without them *****
    '***** Very weird. *****
    '*******************************************************

    Edit: Fail :(
  • Raw 2009-06-01 09:06
    I've seen that problem happen occasionally in some older VB version (probably VB4, it was buggy as hell). I never managed to figure out the logic behind it, but it certainly did happen, and the solution was to put an empty Else clause.

    So, there is a WTF, but it's not the programmer, it's Microsoft.
  • Flipper 2009-06-01 09:11
    Raw:
    I've seen that problem happen occasionally in some older VB version (probably VB4, it was buggy as hell). I never managed to figure out the logic behind it, but it certainly did happen, and the solution was to put an empty Else clause.

    So, there is a WTF, but it's not the programmer, it's Microsoft.

    No, the WTF is the programmer, who has heard at least 17,000 times that Microsoft == WTF^WTF^2, but continues to use it. And some don't even stop there, working hard to staunchly defend the sloppiest crud in the known universe.
  • snoofle 2009-06-01 09:11
    That's not so bad... inexperienced programmer.

    I once spent a lot of time trying to figure out why "x" was incrementing in something (I inherited) like this:


    int x = 1;
    /**++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++ This is a long comment of a lot of text that ++
    ++ had absolutely no redeeming value except that ++
    ++ it could easily */x++/** mislead you into making ++
    ++ your eye skip right past the relevant part in ++
    ++ the middle of the block of unending comments. ++
    ++++++++++++++++++++++++++++++++++++++++++++++++++++*/;


    After that one, we learned to look for the telltale comment-with-semicolon and then scanned backwards.

    For those who care, the guy was indeed sabotaging the code, and was fired 3 weeks later (big corp, wheels grind slowly).
  • chadsexington 2009-06-01 09:14
    snoofle:
    That's not so bad... inexperienced programmer.

    I once spent a lot of time trying to figure out why "x" was incrementing in something (I inherited) like this:


    int x = 1;
    /**++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++ This is a long comment of a lot of text that ++
    ++ had absolutely no redeeming value except that ++
    ++ it could easily */x++/** mislead you into making ++
    ++ your eye skip right past the relevant part in ++
    ++ the middle of the block of unending comments. ++
    ++++++++++++++++++++++++++++++++++++++++++++++++++++*/;


    I think I just found my new programming style.
  • Bob 2009-06-01 09:15
    snoofle:

    ++ it could easily */x++/** mislead you into making ++

    Awesome! I'm going to start using that.

  • T $ 2009-06-01 09:15
    Raw:
    I've seen that problem happen occasionally in some older VB version (probably VB4, it was buggy as hell). I never managed to figure out the logic behind it, but it certainly did happen, and the solution was to put an empty Else clause.


    I can believe it. I'm curious though, would this mean that the compiler bounces back an error without it, the program would issue a runtime exception, or is it executing everything past the end if only if the condition is true.
  • Voodoo Coder 2009-06-01 09:16
    sponk:
    That's a bit of a mild wtf. Someone isn't very good at programming. Oh no.
    At least they tried to figure out and fix whatever was going wrong, even if they didn't understand it.


    Isn't that kind of, the essence of TDWTF? People who are not very good at programming?

    Cargo Cult Programming is never anything other than a WTF. If you don't know WHY something works, find out.
  • Raw 2009-06-01 09:24
    No, the WTF is the programmer, who has heard at least 17,000 times that Microsoft == WTF^WTF^2, but continues to use it.


    Well, in most workplaces, you really don't get the option to pick your favourite language.

    I once spent a lot of time trying to figure out why "x" was incrementing in something (I inherited) like this:


    Now, that's why you use an editor which color-codes the code, and set it to display comments with another background color.

    I can believe it. I'm curious though, would this mean that the compiler bounces back an error without it, the program would issue a runtime exception, or is it executing everything past the end if only if the condition is true.


    Now, this was a decade ago, so my memory is kind of blurry, but when I got it, I got it in a nested if, which meant that it skipped to the wrong endif, and the error occured later. Took me a while to hunt it down, and a lot of swearing to try to find out WTF happened and why.

    Cargo Cult Programming is never anything other than a WTF. If you don't know WHY something works, find out.


    Unless you have a way overdue deadline. Then you just ship it and check it out later.
  • Frzr 2009-06-01 09:26
    int fancy_check(int *x, int *y)
    {
    if (*y==0 /* can't work with y=0 */
    || *x/*y==*y /* can't work on squares */
    || *x==3) /* I hate the number three */
    return 0;
    else return 1;
    }

    int main(int argc, char *argv[])
    {
    int x,y;
    x=0; y=1; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    x=9; y=3; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    return 0;
    }
  • SomeGuy 2009-06-01 09:27
    Raw:

    Unless you have a way overdue deadline. Then you just ship it and check it out later.


    How often does checking it out later actually happen?
  • No one of importance 2009-06-01 09:28
    Have a look at the principles of job-extension methodology: "How to Write Unmaintainable Code,"

    http://freeworld.thc.org/root/phun/unmaintain.html
  • Matt 2009-06-01 09:35
    I'll second it... I remember running into the problem as well. Not sure which version of VB as I dealt with VB3-->VB6 but the problem definately existed. Totally weird, could have been the compiler or IDE, but they still had less bugs and crashes than Visual Studio 2008 SP1.
  • Raw 2009-06-01 09:44
    SomeGuy:
    How often does checking it out later actually happen?


    Every time it later blows up unexpectedly.

    That's the problem when the boss isn't a programmer, "it works at the moment" is good enough for the boss.
  • brazzy 2009-06-01 09:52
    How exactly does writing software that can be consistent sold for enough money to keep a company running NOT constitute "real-world experience"??

    If anything, it's people who don't consider stupid cargo cult programming to be absolutely normal and something you have to expect and deal with who are lacking "real-world experience".
  • TRWTF 2009-06-01 09:53
    chadsexington:
    snoofle:
    That's not so bad... inexperienced programmer.

    I once spent a lot of time trying to figure out why "x" was incrementing in something (I inherited) like this:


    int x = 1;
    /**++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++ This is a long comment of a lot of text that ++
    ++ had absolutely no redeeming value except that ++
    ++ it could easily */x++/** mislead you into making ++
    ++ your eye skip right past the relevant part in ++
    ++ the middle of the block of unending comments. ++
    ++++++++++++++++++++++++++++++++++++++++++++++++++++*/;


    I think I just found my new programming style.


    And you have not submitted this as a story because...? Hell, just spill it here in the comments. Everyone knows the coder based WTF gets less than half the views of the blue bar stories anyway.
  • snoofle 2009-06-01 09:56
    Raw:

    I once spent a lot of time trying to figure out why "x" was incrementing in something (I inherited) like this:


    Now, that's why you use an editor which color-codes the code, and set it to display comments with another background color.

    Today, yes. But that happened before the days of IDEs. You had two windows: vi and the debugger, and all the debugger showed was (pseudo)

    sto x,1
    inc x
    whatever-came-next

    Then you looked at the code window and had to find it in the jumble of comments.
  • ricecake 2009-06-01 10:03
    No one of importance:
    Have a look at the principles of job-extension methodology: "How to Write Unmaintainable Code,"

    http://freeworld.thc.org/root/phun/unmaintain.html
    Here's the updated version:
    http://mindprod.com/jgloss/unmain.html
  • snoofle 2009-06-01 10:09
    TRWTF:

    And you have not submitted this as a story because...? Hell, just spill it here in the comments. Everyone knows the coder based WTF gets less than half the views of the blue bar stories anyway.

    Sorry, I didn't think it was a WTF so much as an infantile fool throwing a tantrum.
  • PT 2009-06-01 10:10
    I've worked on VB3 code way back when, where the developer actually showed me that removing a comment caused the app to shut down when it was to be executed. it was making a lot of calls to C code, and for somereason that one method needed:

    'do not delete this comment, or try a compile wihtout it beforechecking in to sourcesafe
  • Code Dependent 2009-06-01 10:17
    snoofle:
    Today, yes. But that happened before the days of IDEs. You had two windows: vi and the debugger
    This is VB we're talking about. At my first professional coding job, I assumed we would be using C++, but was told that the company used VB for rapid application development. VB4 was just being released at that time, and I had to do a quick ramp-up with it. As I recall, the IDE displayed comments in a different color by that time.

    Addendum (2009-06-01 10:27):
    Oops... my mistake; sorry. Note to self: read more carefully next time.
  • ubersoldat 2009-06-01 10:24
    snoofle:
    For those who care, the guy was indeed sabotaging the code, and was fired 3 weeks later (big corp, wheels grind slowly).


    Another reason to use CVS and the email on commit plugin. If I ever see a comment like this I'll give you gummy bears to play while you wait for your FIRED email.
  • Zarkonnen 2009-06-01 10:54
    Literate programming?

    *ducks*
  • Shinobu 2009-06-01 11:05
    I still use VB4 today. The main reason is that the IDE is up within seconds, so very nice if I want to hack up a quicky. Although I've found some weird things, on the whole I must say that it's very robust, especially considering that a) it's 2009 now and it still works with all the new things I throw at it even though it came out in 1995 or so and b) that I'm a bloody code contortionist who likes to do strange low-level things for a hobby.
  • Code Dependent 2009-06-01 11:13
    Shinobu:
    I still use VB4 today. The main reason is that the IDE is up within seconds, so very nice if I want to hack up a quicky.
    I liked the IDE for VB4, with its arrangement of individual windows. The next version, VB97, started using the MDI and child windows, and it's been that way ever since. But I don't get using VB4. If you don't want to go to .Net, why not at least move up to VB6?
  • Steve 2009-06-01 11:16
    Reminds me of a time when someone left a comment in the code about how the error handling sucked (VB 6).

    There was a follow-up comment from my supervisor. Something along the lines of "what kind of an a-hole would leave a comment complaining about the error-handling without bothering to fix it? come and discuss this with me if you have the guts."

  • Monkios 2009-06-01 11:23
    As expected, this is a comment as expected.
  • Old fart 2009-06-01 11:40
    It may be related to a known bug in VB6 that occurs if an in-line If statement is nested in an If / End If block, e.g.:

    If blnCondition1 then
    If blnCondition2 then (do something here on this line
    Else
    (do something else here)
    End If

    The nested If must be accompanied with a corresponding End If to avoid the bug. Don't know how this got past the QA when VB6 was released

  • aristos_achaion 2009-06-01 11:50
    Voodoo Coder:
    sponk:
    That's a bit of a mild wtf. Someone isn't very good at programming. Oh no.
    At least they tried to figure out and fix whatever was going wrong, even if they didn't understand it.


    Isn't that kind of, the essence of TDWTF? People who are not very good at programming?

    Cargo Cult Programming is never anything other than a WTF. If you don't know WHY something works, find out.

    Usually there's some kind of hubris or massive ineptitude forming the core of the WTF...in this case, it's mild inexperience and laziness. Evidently, it didn't work without the Else, so he put one in, and commented his change.
  • aristos_achaion 2009-06-01 11:52
    Code Dependent:
    Shinobu:
    I still use VB4 today. The main reason is that the IDE is up within seconds, so very nice if I want to hack up a quicky.
    I liked the IDE for VB4, with its arrangement of individual windows. The next version, VB97, started using the MDI and child windows, and it's been that way ever since. But I don't get using VB4. If you don't want to go to .Net, why not at least move up to VB6?

    Personally, I don't get using VB, or Windows for that matter. But different strokes for different folks, I guess.
  • Satanicpuppy 2009-06-01 11:53
    snoofle:
    That's not so bad... inexperienced programmer.

    I once spent a lot of time trying to figure out why "x" was incrementing in something (I inherited) like this:


    int x = 1;
    /**++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++ This is a long comment of a lot of text that ++
    ++ had absolutely no redeeming value except that ++
    ++ it could easily */x++/** mislead you into making ++
    ++ your eye skip right past the relevant part in ++
    ++ the middle of the block of unending comments. ++
    ++++++++++++++++++++++++++++++++++++++++++++++++++++*/;


    After that one, we learned to look for the telltale comment-with-semicolon and then scanned backwards.

    For those who care, the guy was indeed sabotaging the code, and was fired 3 weeks later (big corp, wheels grind slowly).


    Hah, that's amusing. I spend a lot of my time undoing that sort of sabotage, and that's really an amateurish way of doing it...Though it is somewhat clever, anyone who looked at it would immediately know that that was intentional obfuscation.

    It's a lot easier to just move stuff around weirdly, and use a lot of duplicate filenames/variable names and crap like that.
  • Zer0 2009-06-01 11:57
    sponk:
    That's a bit of a mild wtf. Someone isn't very good at programming. Oh no.
    At least they tried to figure out and fix whatever was going wrong, even if they didn't understand it.


    Uh, if you've ever done that yourself, get out of this industry. I really don't ever want to run across and fix our code. Thanks =)
  • Ray 2009-06-01 12:04
    Frzr:
    int fancy_check(int *x, int *y)
    {
    if (*y==0 /* can't work with y=0 */
    || *x/*y==*y /* can't work on squares */
    || *x==3) /* I hate the number three */
    return 0;
    else return 1;
    }

    int main(int argc, char *argv[])
    {
    int x,y;
    x=0; y=1; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    x=9; y=3; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    return 0;
    }


    Color highlighting shows the mistake right away.
    Nice try. :)
  • Jasmine 2009-06-01 12:06
    aristos_achaion:
    Voodoo Coder:
    sponk:
    That's a bit of a mild wtf. Someone isn't very good at programming. Oh no.
    At least they tried to figure out and fix whatever was going wrong, even if they didn't understand it.


    Isn't that kind of, the essence of TDWTF? People who are not very good at programming?

    Cargo Cult Programming is never anything other than a WTF. If you don't know WHY something works, find out.

    Usually there's some kind of hubris or massive ineptitude forming the core of the WTF...in this case, it's mild inexperience and laziness. Evidently, it didn't work without the Else, so he put one in, and commented his change.


    They did what needed to be done to make it work, and it's hard to disagree with that. The RWTF is how often that happens and is never re-visited for improvement - and the fact that it did work without the else.
  • pitchingchris 2009-06-01 12:23
    Jasmine:

    They did what needed to be done to make it work, and it's hard to disagree with that. The RWTF is how often that happens and is never re-visited for improvement - and the fact that it did work without the else.


    How is it a WTF that it did work without the else ? There isn't any code in the else to do anything, so it would perform the same way in both cases.

    Its kind of lame wtf today, it just looks like some comments that somebody new to debugging probably put in there. Even though its senseless and should be removed, its just the mark of a beginner. It has no real affect, as already mentioned. The main issue is that debugging comments made it into source control (if one is used). These should be reviewed before committing.
  • Leak 2009-06-01 12:31
    Old fart:
    It may be related to a known bug in VB6 that occurs if an in-line If statement is nested in an If / End If block, e.g.:

    If blnCondition1 then
    If blnCondition2 then (do something here on this line
    Else
    (do something else here)
    End If

    The nested If must be accompanied with a corresponding End If to avoid the bug. Don't know how this got past the QA when VB6 was released

    That looks more like a dangling else to me...

    np: The Wooden Birds - False Alarm (Magnolia)
  • Jasmine 2009-06-01 12:37
    pitchingchris:
    Jasmine:

    They did what needed to be done to make it work, and it's hard to disagree with that. The RWTF is how often that happens and is never re-visited for improvement - and the fact that it did work without the else.


    How is it a WTF that it did work without the else ? There isn't any code in the else to do anything, so it would perform the same way in both cases.

    Its kind of lame wtf today, it just looks like some comments that somebody new to debugging probably put in there. Even though its senseless and should be removed, its just the mark of a beginner. It has no real affect, as already mentioned. The main issue is that debugging comments made it into source control (if one is used). These should be reviewed before committing.


    I just think it's suspicious that someone obviously had a problem without putting the else, and then someone else later on had it work fine. I've been doing this stuff for 25 years, and I've seen this kind of thing a few times, and the one reasonable explanation for it has been updates to the compilers/interpreters between the first and second revisions. When you can't find an explanation like that, it is just suspicious and you go with it. In business you do whatever it takes to get the job done, and if you don't understand it, then you're welcome to have a bad feeling about that, but you're going to do it anyway. I vaguely recall VB doing this kind of thing - it would cause a runtime error.

    This is definitely a WTF - but you see this kind of thing occasionally. I've seen perfect code maybe once in my life - and I wrote it, in college - which is the only place perfect coding happens on a regular basis.
  • jacmoe 2009-06-01 12:38
    I really don't think it's a WTF.
    It was a bug in VB, so they worked around it.
    And because they didn't want to look stupid, or someone removing the empty else statement, they wrote a comment. A WTF comment, but a comment none the less. :)
  • Kluge Doctor 2009-06-01 12:43
    snoofle:


    int x = 1;
    /**++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++ This is a long comment of a lot of text that ++
    ++ had absolutely no redeeming value except that ++
    ++ it could easily */x++/** mislead you into making ++
    ++ your eye skip right past the relevant part in ++
    ++ the middle of the block of unending comments. ++
    ++++++++++++++++++++++++++++++++++++++++++++++++++++*/;





    int x = 1;
    /**++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++ This is a long comment of a lot of text that ++
    ++ had absolutely no redeeming value except that ++
    ++ it could easily */x++;/** mislead you into making ++
    ++ your eye skip right past the relevant part in ++
    ++ the middle of the block of unending comments. ++
    ++++++++++++++++++++++++++++++++++++++++++++++++++++*/;


    Fixed.
  • Been there done that 2009-06-01 12:45
    This was a rare bug in VB3 during 1993-1994 and was fixed in VB4 by 1995. The workaround was as described int eh original code above.
  • Redundant Semicolon 2009-06-01 12:54
    Kluge Doctor:
    snoofle:


    int x = 1;
    /**++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++ This is a long comment of a lot of text that ++
    ++ had absolutely no redeeming value except that ++
    ++ it could easily */x++/** mislead you into making ++
    ++ your eye skip right past the relevant part in ++
    ++ the middle of the block of unending comments. ++
    ++++++++++++++++++++++++++++++++++++++++++++++++++++*/;





    int x = 1;
    /**++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++ This is a long comment of a lot of text that ++
    ++ had absolutely no redeeming value except that ++
    ++ it could easily */x++;/** mislead you into making ++
    ++ your eye skip right past the relevant part in ++
    ++ the middle of the block of unending comments. ++
    ++++++++++++++++++++++++++++++++++++++++++++++++++++*/;


    Fixed.


    You shouldn't fix what is not broken :)
  • aggle-rithm 2009-06-01 12:55
    snoofle:

    For those who care, the guy was indeed sabotaging the code, and was fired 3 weeks later (big corp, wheels grind slowly).


    "I swear to God, if you sabotage any more code, I will start the disciplinary process!!!"
  • jmroth 2009-06-01 13:18
    Probably the 'End If' was on the same line as one of the comment lines :P
    To make it worse, line wrapping probably put the 'End If' at the beginning of a line :P
  • Pim 2009-06-01 13:22
    Ray:
    Frzr:
    int fancy_check(int *x, int *y)
    {
    if (*y==0 /* can't work with y=0 */
    || *x/*y==*y /* can't work on squares */
    || *x==3) /* I hate the number three */
    return 0;
    else return 1;
    }

    int main(int argc, char *argv[])
    {
    int x,y;
    x=0; y=1; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    x=9; y=3; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    return 0;
    }


    Color highlighting shows the mistake right away.
    Nice try. :)
    Color highlighting? You mean you actually had to paste that into an IDE before you could see it?
    :: giggles ::
  • SomeCoder 2009-06-01 13:31
    Ray:
    Frzr:
    int fancy_check(int *x, int *y)
    {
    if (*y==0 /* can't work with y=0 */
    || *x/*y==*y /* can't work on squares */
    || *x==3) /* I hate the number three */
    return 0;
    else return 1;
    }

    int main(int argc, char *argv[])
    {
    int x,y;
    x=0; y=1; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    x=9; y=3; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    return 0;
    }


    Color highlighting shows the mistake right away.
    Nice try. :)


    This is exactly why I it when people format their code that way. What is wrong with adding spaces in there:

    if (*x / *y)

    rather than

    if (*x/*y)

    which not only doesn't work but looks bad anyway.

    Oh well :)
  • Code Dependent 2009-06-01 13:45
    aristos_achaion:
    Personally, I don't get using VB, or Windows for that matter. But different strokes for different folks, I guess.
    As has often been pointed out here, and even by me in an earlier post in this thread, you don't always get to choose your OS or programming language. Especially in a town of population 85,000, where you will be lucky if there are a dozen programming positions in the whole town, nevermind you actually getting hired for one of them (which happens when somebody dies or moves away).
  • Americium 2009-06-01 13:50
    T $:
    Raw:
    I've seen that problem happen occasionally in some older VB version (probably VB4, it was buggy as hell). I never managed to figure out the logic behind it, but it certainly did happen, and the solution was to put an empty Else clause.


    I can believe it. I'm curious though, would this mean that the compiler bounces back an error without it, the program would issue a runtime exception, or is it executing everything past the end if only if the condition is true.


    I just discovered a similar bug in Python. Prior to version 2.5, The finally block couldn't exist without an except (same as catch).

    try:
    f = open('./file.txt')
    # ...
    # Error in Py2.4- due to no except:
    finally:
    f.close()

    These are both parser design flaws. if without else and try without except are probably difficult cases. See the topic if-statement dangling-else on compilers.
  • Soviut 2009-06-01 14:29
    Flipper:
    No, the WTF is the programmer, who has heard at least 17,000 times that Microsoft == WTF^WTF^2, but continues to use it. And some don't even stop there, working hard to staunchly defend the sloppiest crud in the known universe.


    Naturally, because Microsoft is well known for their horrible tools, non-existent IDEs, unpopular languages, lack of documentation and poor community support. Microsoft hates developers.

    END SARCASM
  • John Flack 2009-06-01 14:33
    I once worked with a compiler with a very odd bug - any program with a line count that was a multiple of 256 would not compile. Believe me, it took a while for us to figure out what was wrong - add a debugging line, and this would change the line count and the program would work fine. Remove it, and it would be back at the magic line count - no compile. Fix - counted lines and added a comment when needed.
  • frank 2009-06-01 14:46
    John Flack:
    I once worked with a compiler with a very odd bug - any program with a line count that was a multiple of 256 would not compile. Believe me, it took a while for us to figure out what was wrong - add a debugging line, and this would change the line count and the program would work fine. Remove it, and it would be back at the magic line count - no compile. Fix - counted lines and added a comment when needed.


    Fix - get a new compiler...
  • Cloud 9 2009-06-01 14:51
    aggle-rithm:
    snoofle:

    For those who care, the guy was indeed sabotaging the code, and was fired 3 weeks later (big corp, wheels grind slowly).


    "I swear to God, if you sabotage any more code, I will start the disciplinary process!!!"


    Beeeep

    You have reached the phone of God.
    God is unable to come to the phone right now - being busy dealing with complaints from The Meek who are irate at not having received their promised inheritance.
    Please leave a message after the extract from The Hallelujah Chorus.
  • Techpaul 2009-06-01 15:21
    For weird bugs in VB6 inbuilt functions have a look at this -

    ----
    Dim val As Long

    val = &HA5A5 'assign a UNSIGNED LONG value

    val = 42405 'assign a signed LONG decimal value

    ----

    Try single stepping (or adding your own output functions), note the numbers you get assigned to val.

    For those who don't see it straight away you SHOULD get the SAME number each time, but you don't!

    For those who think why use hex, well for that control application of always sending 32 bit values, and in this case the bit fields matched up in 4 bit fields to actual relays being switched it makes perfect sense for programme description matching hardware.

    Note that VB6 on longs properly converts hex numbers &H0 to &H7FFF, and &H10000 to &HFFFFFFFF.

  • iMalc 2009-06-01 15:25
    Raw:
    I've seen that problem happen occasionally in some older VB version (probably VB4, it was buggy as hell). I never managed to figure out the logic behind it, but it certainly did happen, and the solution was to put an empty Else clause.
    I can confirm this. In the short time I user VB4 I certainly ran into code that would fail to execute corrrectly and required a stupid little workaround a bit different to the one here, but hey I never tried the dangling else to solve it back then.
  • kaetuu89 2009-06-01 15:49
    Gee Sponk.. They tried to understand it, even if they didn't figure it out and fixed it. Kind of like our new president.. Doesn't understand how it all works, but that won't stop him from fixing it... Dam da torpedos.. full steam ahead!!
  • kaetuu89 2009-06-01 15:51
    and the programmers who sacked programmers who sacked programmers who sacked the programmers who wrote the vb code were.. sacked.
  • Ric Ambrose 2009-06-01 16:14
    HA HA HA, poor bastards, they had a ref or something confused on their system with the Word VBA...

    Been there....
  • boingle 2009-06-01 16:33
    I've said it a million times before.

    B EGINNNERS
    A ll purpose
    S ymbolic
    I nstruction
    C ode

    What more do you expect from beginners?
  • chrismcb 2009-06-01 16:37
    sponk:
    Someone isn't very good at programming.


    And hence the reason for the majority of the WTFs here.

  • Sparr 2009-06-01 16:47
    Interestingly enough, I actually found (and reported and saw fixed) a bug in gcc's m68k optimizer of exactly this sort. The jmp portion of a conditional block was emitted incorrectly in a very particular case, which I encountered when I removed an else{nop()} block from my code, and bypassed by putting the else{nop()} back in.

    (nop() was a one-line inlined function that produced an asm NOP instruction)
  • BikeHelmet 2009-06-01 17:00
    Else
    '*******************************************************
    '***** DO NOT REMOVE THE ELSE. *****
    '***** Program is skipping the End If without it. *****
    '***** Very weird. *****
    '*******************************************************
    End If

    I'm inclined to believe the guy.

    I once had this line of java fail to compile:

    if(verifyData(sData)) plotChart(sData);

    Error message? Missing semicolon. I copied the source to a new file in another project, and it compiled just fine. But for whatever reason, the main project thought it had a missing semicolon.

    I cleaned the project, rebuilt from scratch, and still a missing semicolon. Closed the IDE, re-opened it, and still the missing semicolon.

    I added the ornery source file to the other project, and now it wouldn't compile either, because of a missing semicolon.

    So I opened the unworking source file in a hex editor, and the working one, and verified they were absolutely identical. :/

    Could it be my OS? I rebooted the computer, but despite this, it still complained about a missing semicolon.

    I tried deleting the file and creating a new one, but the new one with the same name also complained about a missing semicolon.

    My solution? The program now has class DataChart2 rather than just DataChart.

    I'm sure whoever inherits the program will wonder why the hell it's the only class with a 2 on the end. And when they read the comment "Needs 2 on end of classname to fix missing semicolon error.", it'll probably end up on TDWTF.

    So maybe the interpreter was skipping that End If without the Else present. I'm hesitant to disregard this as programmer naiveté/error. After all, Basic interpreters are known for being rock solid. ;)
  • Eh 2009-06-01 17:46
    Ray:
    Frzr:
    int fancy_check(int *x, int *y)
    {
    if (*y==0 /* can't work with y=0 */
    || *x/*y==*y /* can't work on squares */
    || *x==3) /* I hate the number three */
    return 0;
    else return 1;
    }

    int main(int argc, char *argv[])
    {
    int x,y;
    x=0; y=1; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    x=9; y=3; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    return 0;
    }


    Color highlighting shows the mistake right away.
    Nice try. :)


    I know asking questions here is dangerous, but what mistake?

    Yes, viewing this with a syntax highligher makes it look like there's a problem, but that's not with the code itself. gcc 4 compiles and runs this code on Linux and OS X no problem. As far as I can tell, I get the expected response with various parameters:
    3,1 -> 0
    1,0 -> 0
    0,1 -> 1
    9,3 -> 0

    Does Visual C++ fail to compile this?
  • Mike5 2009-06-01 17:49
    SomeGuy:
    Raw:

    Unless you have a way overdue deadline. Then you just ship it and check it out later.


    How often does checking it out later actually happen?


    You know... When the bugs start biting.

    Mike5
  • compiler 2009-06-01 17:49
    END SARCASM
    ^ END found without BEGIN
  • Id10T 2009-06-01 18:03
    Raw:
    I've seen that problem happen occasionally in some older VB version (probably VB4, it was buggy as hell). I never managed to figure out the logic behind it, but it certainly did happen, and the solution was to put an empty Else clause.

    So, there is a WTF, but it's not the programmer, it's Microsoft.


    It always used to happen to me when there was an apostrophe at the beginning of the line....not sure why....
  • Hungry Troll 2009-06-01 18:18
    Code Dependent:
    Shinobu:
    I still use VB4 today. The main reason is that the IDE is up within seconds, so very nice if I want to hack up a quicky.
    I liked the IDE for VB4, with its arrangement of individual windows. The next version, VB97, started using the MDI and child windows, and it's been that way ever since. But I don't get using VB4. If you don't want to go to .Net, why not at least move up to VB6?


    The first billy-goat....
  • Capt. Obvious 2009-06-01 18:19
    For crying out loud. You write a long, detailed explanation of the program on tdwtf, and leave a mere hint in the comment? When I have to do something crazy like that, you'll get a long, detailed comment.

    Now, if my (former) coworker found it, you got profanity.
  • MegaByte 2009-06-01 18:35
    Eh:
    Ray:
    Frzr:
    int fancy_check(int *x, int *y)
    {
    if (*y==0 /* can't work with y=0 */
    || *x/*y==*y /* can't work on squares */
    || *x==3) /* I hate the number three */
    return 0;
    else return 1;
    }

    int main(int argc, char *argv[])
    {
    int x,y;
    x=0; y=1; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    x=9; y=3; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    return 0;
    }


    Color highlighting shows the mistake right away.
    Nice try. :)


    I know asking questions here is dangerous, but what mistake?

    Yes, viewing this with a syntax highligher makes it look like there's a problem, but that's not with the code itself. gcc 4 compiles and runs this code on Linux and OS X no problem. As far as I can tell, I get the expected response with various parameters:
    3,1 -> 0
    1,0 -> 0
    0,1 -> 1
    9,3 -> 0

    Does Visual C++ fail to compile this?


    It depends what you expect to be the response, I suppose...

    I don't think th epoint was that it doesn't compile, more that it doesn't necessarily behave as expected.

    Read the comments and consider those conditions, just because it works for some cases doesn't m,ean it works for all
    3,1 -> 0 ... Fair enough, we don't like 3
    1, 0 -> 0... Ok, can't work with y =0
    0, 1 -> 1 ... Ok doesn't breach conditions
    9, 3 -> 0 ... Rejected as a square, fair enough....

    Let's try some other ones....

    1, 2 -> 0....Hang on a minute....
    2, 2 -> 0 ...Hmmm...

    Noone was suggesting it wouldn't compile, merely that it may not do what it was intended to....


    [In Hindsight, I think I've been trolled]
  • uzbones 2009-06-01 19:10
    Now it will give you an error because there are two semicolons... The original one is at the end of the comment.
  • jacmoe 2009-06-01 19:22
    The real WTF is that this is not a WTF at all, and most of you guys don't get it. :)
    It's a bug in VB.
    Very little real-world experience?
    How arrogant. I'd have written the same comment.
    At least they didn't write:
    This will not compile without the End If. WTF?!
  • AndyL 2009-06-01 19:23
    At least the original programmer successfully identified that it was "Very Weird".

    It would have been worse if he or she had simply accepted this as The Way Things Work and put empty else clauses on every if block in the codebase.
  • too_many_usernames 2009-06-01 19:47
    AndyL:
    At least the original programmer successfully identified that it was "Very Weird".

    It would have been worse if he or she had simply accepted this as The Way Things Work and put empty else clauses on every if block in the codebase.

    Unless, of course, you're following something like MISRA and you get penalized if you don't put empty else clauses to explicitly show you don't want to do an action there.
  • tgape 2009-06-01 20:33
    Zer0:
    sponk:
    That's a bit of a mild wtf. Someone isn't very good at programming. Oh no.
    At least they tried to figure out and fix whatever was going wrong, even if they didn't understand it.


    Uh, if you've ever done that yourself, get out of this industry. I really don't ever want to run across and fix our code. Thanks =)


    Depending upon what you mean, I may agree or disagree.

    Once upon a time, I encountered a similar error in a C compiler. This was a production down situation, so I confirmed how to proceed with my supervisor, fixed it with a comment, and then came in the next Saturday, and futzed around with it until I found out what the actual compiler error was. Finally, I modified the logic so that it was unlikely a simple change would re-invoke the bug, documented the bug in the revision control log, put it through review, and rolled it into production three weeks later.

    Do I qualify for your recommendation to get out of the industry?
  • Val 2009-06-01 20:50
    Bob:
    snoofle:

    ++ it could easily */x++/** mislead you into making ++

    Awesome! I'm going to start using that.



    That's not misleading
    THIS is misleading:


    x=y;
    // This block of comment explains the important /
    // differences between the values of x and y /
    // blablabla blablabla blablabla blablabla /
    // /
    // Edit: /
    // x must be always greater !! Weird, isn't it??/
    x++;

    //...
    if (x>y)
    {
    // ...
    }
    else
    {
    // epic fail!
    }
  • AndyCanfield 2009-06-01 20:55
    OK, I'll reveal what others seems to have found faster than I did.

    A problem is in this line:
    || *x/*y==*y /* can't work on squares */
    It looks as if it means:
    || (*x)/(*y) == (*y)
    but it really means:
    || (*x)
    because the /*y starts a comment. Yeah, it took me a second pass to see it.
  • Jon H 2009-06-01 21:15
    I recall back in 1994 I was working with Visual C++ on NT. I encountered a source code file that had acquired an invisible control character; when opened in Visual C++, the whole OS would crash. It was quite impressive.

    Had to open the file on a NeXT machine to find the problem and fix it.
  • Christopher 2009-06-01 22:02
    uzbones:
    Now it will give you an error because there are two semicolons... The original one is at the end of the comment.
    No, it won't give an error. C allows lone semicolons. It calls these "null statements", and they can be put wherever a statement can go.
    For example, the following C code will compile without errors (and should compile without warnings):
    ;;;;;;;;;;
    
    int main()
    {
    ;;;;;;;;;;;;;
    return 0;;;;;
    }
  • resa 2009-06-01 22:27
    Raw:
    I've seen that problem happen occasionally in some older VB version (probably VB4, it was buggy as hell). I never managed to figure out the logic behind it, but it certainly did happen, and the solution was to put an empty Else clause.

    So, there is a WTF, but it's not the programmer, it's Microsoft.


    VB3/4 had all kinds of weird buggy shit like that.
  • resa 2009-06-01 22:30
    jacmoe:
    The real WTF is that this is not a WTF at all, and most of you guys don't get it. :)
    It's a bug in VB.
    Very little real-world experience?
    How arrogant. I'd have written the same comment.
    At least they didn't write:
    This will not compile without the End If. WTF?!


    I used to always comment that weird buggy shit and I'm sure some arrogant younger asshole with a degree in "Software Engineering" came along and WTF'd years and years after the fact without any effing clue about the olden days.
  • Ronuk Raval 2009-06-01 23:00
    I don't believe no one has pointed it out yet, but the tricky line, "*x/*y==*y /* can't work on squares */", will cause any decently set up C compiler to at least warn about a nested comment.

    Admittingly, gcc seems to require a little prodding to display the warning (requiring -Wall). But then again, you are turning all warnings on, right?!
  • korvaks 2009-06-01 23:32
    Try this one, I know it produces interesting results under gcc:

    /* c code test file */
    #include <stdio.h>

    int main() {
    int x;
    x = 0;
    // start a block comment \\
    /* I don't want to increment x
    x++;
    // end the block comment \\
    */

    printf("The value of x is %d\n", x);
    return 0;
    }


    Without compiling, what result would you expect? What do you actually get?
  • Jongles 2009-06-01 23:57
    korvaks:
    Try this one, I know it produces interesting results under gcc:

    /* c code test file */
    #include <stdio.h>

    int main() {
    int x;
    x = 0;
    // start a block comment \\
    /* I don't want to increment x
    x++;
    // end the block comment \\
    */

    printf("The value of x is %d\n", x);
    return 0;
    }


    Without compiling, what result would you expect? What do you actually get?

    I expected 0 and got 0.....

    Did I miss something?? (YES, I DID use gcc)
  • korvaks 2009-06-02 00:02
    Jongles:
    korvaks:
    Try this one, I know it produces interesting results under gcc:

    /* c code test file */
    #include <stdio.h>

    int main() {
    int x;
    x = 0;
    // start a block comment \\
    /* I don't want to increment x
    x++;
    // end the block comment \\
    */

    printf("The value of x is %d\n", x);
    return 0;
    }


    Without compiling, what result would you expect? What do you actually get?

    I expected 0 and got 0.....

    Did I miss something?? (YES, I DID use gcc)



    me@machine$ gcc -version
    gcc (GCC) 3.4.6 20060404
    (blah blah)

    me@machine$ gcc test.c
    me@machine$ ./a.out
    The value of x is 1


    The line starting with /* is part of a single line comment, so is not interpreted as the start of a comment. Same with */.
  • Jongles 2009-06-02 00:05
    korvaks:
    Jongles:
    korvaks:
    Try this one, I know it produces interesting results under gcc:

    /* c code test file */
    #include <stdio.h>

    int main() {
    int x;
    x = 0;
    // start a block comment \\
    /* I don't want to increment x
    x++;
    // end the block comment \\
    */

    printf("The value of x is %d\n", x);
    return 0;
    }


    Without compiling, what result would you expect? What do you actually get?

    I expected 0 and got 0.....

    Did I miss something?? (YES, I DID use gcc)



    me@machine$ gcc -version
    gcc (GCC) 3.4.6 20060404
    (blah blah)

    me@machine$ gcc test.c
    me@machine$ ./a.out
    The value of x is 1


    The line starting with /* is part of a single line comment, so is not interpreted as the start of a comment. Same with */.


    gcc --version
    gcc (GCC) 3.3.2
    Copyright (C) 2003 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    ./a.out
    The value of x is 0


    Must be the later version of gcc...mine is happy, happy
    But I see the point....
  • Jongles 2009-06-02 00:07
    Jongles:
    korvaks:
    Jongles:
    korvaks:
    T
    <snip>





    gcc --version
    gcc (GCC) 3.3.2
    Copyright (C) 2003 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    ./a.out
    The value of x is 0


    Must be the later version of gcc...mine is happy, happy
    But I see the point....


    Oops....my bad....

    Copy and Paste gave me blank line between each line....
    Now I see it!!
  • NewbiusMaximus 2009-06-02 00:43
    Years ago, a coworker stumbled upon a similar problem in one of the Borland C++ compilers. There was an if statement that would only execute its block if there was an else block present. At the time, neither of us could tell by stepping through in the debugger what the hell was going on, so we just added a descriptive comment and went on slogging through our bug list.

    I'm sure if somebody saw that code later, they probably thought we were clueless. I try to remember things like this when I'm tempted to poke fun at some WTF's.
  • Jimmy Jones 2009-06-02 03:09
    >"++ it could easily */x++/** mislead you into making ++"

    So the WTF is that your IDE isn't showing the "x++" in a different color...?

  • Abraham 2009-06-02 04:14
    Indeed, the real WTF is how come Alex never experienced a bug in compiler. The other wtf is the dangling else thing, i've been taught the else always matches to the closest then. As simple as that.
  • Anon 2009-06-02 04:30
    John Flack:
    I once worked with a compiler with a very odd bug - any program with a line count that was a multiple of 256 would not compile. Believe me, it took a while for us to figure out what was wrong - add a debugging line, and this would change the line count and the program would work fine. Remove it, and it would be back at the magic line count - no compile. Fix - counted lines and added a comment when needed.


    Actually counted lines or just wrote a quick script that does it for you and adds/removes empty comments at the end of each files as necessary?
  • EmperorOfCanada 2009-06-02 05:20
    I agree; I don't think that this is an error on the original programmer's part. I suspect a bug fix came along removed the problem.
    I have seen many problems with VB over the years that required similar workarounds. Around vb5 I probably hit two or three oddities like this. So kudos to the original programmer for leaving a good comment instead of an empty else statement.
  • London Developer 2009-06-02 07:26
    sponk:
    That's a bit of a mild wtf. Someone isn't very good at programming. Oh no.
    At least they tried to figure out and fix whatever was going wrong, even if they didn't understand it.


    Yes, so lets just sell it as commercial software, shall we???? AWFUL!!! In most companies I worked for this would have been a sackable offence!!!
  • meyekul 2009-06-02 07:50
    Well they SHOULD understand it if they are working for a software company. Hacks and workarounds like that are part of what leads to security holes and exploits.
  • IByte 2009-06-02 07:53
    snoofle:
    That's not so bad... inexperienced programmer.

    I once spent a lot of time trying to figure out why "x" was incrementing in something (I inherited) like this:


    int x = 1;
    /**++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++ This is a long comment of a lot of text that ++
    ++ had absolutely no redeeming value except that ++
    ++ it could easily */x++/** mislead you into making ++
    ++ your eye skip right past the relevant part in ++
    ++ the middle of the block of unending comments. ++
    ++++++++++++++++++++++++++++++++++++++++++++++++++++*/;


    After that one, we learned to look for the telltale comment-with-semicolon and then scanned backwards.

    For those who care, the guy was indeed sabotaging the code, and was fired 3 weeks later (big corp, wheels grind slowly).
    Syntax highlighting could cut that down to size...
  • ath 2009-06-02 07:58
    snoofle:
    That's not so bad... inexperienced programmer.

    I once spent a lot of time trying to figure out why "x" was incrementing in something (I inherited) like this:


    int x = 1;
    /**++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++ This is a long comment of a lot of text that ++
    ++ had absolutely no redeeming value except that ++
    ++ it could easily */x++/** mislead you into making ++
    ++ your eye skip right past the relevant part in ++
    ++ the middle of the block of unending comments. ++
    ++++++++++++++++++++++++++++++++++++++++++++++++++++*/;


    After that one, we learned to look for the telltale comment-with-semicolon and then scanned backwards.

    For those who care, the guy was indeed sabotaging the code, and was fired 3 weeks later (big corp, wheels grind slowly).


    That just takes the concept of self-documenting code one step further: self-coding-documents!

  • DaveK 2009-06-02 08:19
    Ray:
    Frzr:
    int fancy_check(int *x, int *y)
    {
    if (*y==0 /* can't work with y=0 */
    || *x/*y==*y /* can't work on squares */
    || *x==3) /* I hate the number three */
    return 0;
    else return 1;
    }

    int main(int argc, char *argv[])
    {
    int x,y;
    x=0; y=1; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    x=9; y=3; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    return 0;
    }


    Color highlighting shows the mistake right away.
    Nice try. :)
    Even more importantly, you don't ever compile without warnings turned on, do you?


    $ gcc -x c -Wall -W -
    int fancy_check(int *x, int *y)
    {
    if (*y==0 /* can't work with y=0 */
    || *x/*y==*y /* can't work on squares */
    || *x==3) /* I hate the number three */
    return 0;
    else return 1;
    }

    int main(int argc, char *argv[])
    {
    int x,y;
    x=0; y=1; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    x=9; y=3; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    return 0;
    }


    <stdin>:4:14: warning: "/*" within comment
    <stdin>: In function 'main':
    <stdin>:13: warning: implicit declaration of function 'printf'
    <stdin>:13: warning: incompatible implicit declaration of built-in function 'printf'
    <stdin>: At top level:
    <stdin>:10: warning: unused parameter 'argc'
    <stdin>:10: warning: unused parameter 'argv'
  • ClaudeSuck.de 2009-06-02 08:30
    Raw:
    I've seen that problem happen occasionally in some older VB version (probably VB4, it was buggy as hell). I never managed to figure out the logic behind it, but it certainly did happen, and the solution was to put an empty Else clause.

    So, there is a WTF, but it's not the programmer, it's Microsoft.


    I used to come across this one in Access 2.0 VBA:

    If txtMyText Is Null Then
    DoSomething
    End If

    This never worked as intended (do something when field is empty coz the bloody thing was either NULL or "". In case of "" the If was wrong. The solution was:

    If NOT(txtMyText) Is Null Then
    Else
    DoSomething
    End If

  • ClaudeSuck.de 2009-06-02 08:33
    Bob:
    snoofle:

    ++ it could easily */x++/** mislead you into making ++

    Awesome! I'm going to start using that.



    Unfortunately, VB isn't mean enough to allow you doing this.
  • hatterson 2009-06-02 09:36
    DaveK:
    Ray:
    Frzr:
    int fancy_check(int *x, int *y)
    {
    if (*y==0 /* can't work with y=0 */
    || *x/*y==*y /* can't work on squares */
    || *x==3) /* I hate the number three */
    return 0;
    else return 1;
    }

    int main(int argc, char *argv[])
    {
    int x,y;
    x=0; y=1; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    x=9; y=3; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    return 0;
    }


    Color highlighting shows the mistake right away.
    Nice try. :)
    Even more importantly, you don't ever compile without warnings turned on, do you?


    $ gcc -x c -Wall -W -
    int fancy_check(int *x, int *y)
    {
    if (*y==0 /* can't work with y=0 */
    || *x/*y==*y /* can't work on squares */
    || *x==3) /* I hate the number three */
    return 0;
    else return 1;
    }

    int main(int argc, char *argv[])
    {
    int x,y;
    x=0; y=1; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    x=9; y=3; printf("%d,%d -> %d\n", x,y,fancy_check(&x,&y));
    return 0;
    }


    <stdin>:4:14: warning: "/*" within comment
    <stdin>: In function 'main':
    <stdin>:13: warning: implicit declaration of function 'printf'
    <stdin>:13: warning: incompatible implicit declaration of built-in function 'printf'
    <stdin>: At top level:
    <stdin>:10: warning: unused parameter 'argc'
    <stdin>:10: warning: unused parameter 'argv'
    Of course I do, after all you can safely ignore 100% of warnings and 34% of errors.
  • NH 2009-06-02 11:05
    Flipper:
    Raw:
    I've seen that problem happen occasionally in some older VB version (probably VB4, it was buggy as hell). I never managed to figure out the logic behind it, but it certainly did happen, and the solution was to put an empty Else clause.

    So, there is a WTF, but it's not the programmer, it's Microsoft.

    No, the WTF is the programmer, who has heard at least 17,000 times that Microsoft == WTF^WTF^2, but continues to use it. And some don't even stop there, working hard to staunchly defend the sloppiest crud in the known universe.


    It has unfortunately been all too common with compiler bugs like that, so I won't say that a defensive programming action is a WTF. The only WTF is the compiler that required that kind of programming once.

    And since code like that doesn't do anything neither harmful nor harmless it's not a priority to clean it out.

    I'm even wondering why this made the WTF blog.
  • Ilya Ehrenburg 2009-06-02 16:28
    London Developer:
    sponk:
    That's a bit of a mild wtf. Someone isn't very good at programming. Oh no.
    At least they tried to figure out and fix whatever was going wrong, even if they didn't understand it.


    Yes, so lets just sell it as commercial software, shall we???? AWFUL!!! In most companies I worked for this would have been a sackable offence!!!

    What would be the sackable offence?
    Running into a compiler bug and finding a workaround?
    Or leaving a comment explaining the workaround?
  • NOPIK 2009-06-03 00:27
    Short IF ... THEN form leaks stack.
    And VB doesn't report overflow, when it caused by "nested" operators or parentnesses.
    So, when you put ELSE, you will "close" several IFs up.
    To avoid this bug, every IF must have ENDIF (compiler will check stack overflow before ENDIF)
  • Tintazul 2009-06-03 07:59
    Ohh, skipping the End If! What would they do if they were progamming in Python to prevent the program exection from "skipping the lack of indentation in following line"? Sheesh.
  • Random832 2009-06-03 08:58
    Tintazul:
    Ohh, skipping the End If! What would they do if they were progamming in Python to prevent the program exection from "skipping the lack of indentation in following line"? Sheesh.


    Presumably there would be no possible workaround if the Python interpreter had a bug like this, so they'd just not use Python.
  • Stephen 2009-06-03 09:44
    SomeGuy:
    Raw:

    Unless you have a way overdue deadline. Then you just ship it and check it out later.


    How often does checking it out later actually happen?


    I'd say 99.99% of the uptime. I mean time. I've been way behind and tried to cut corners in testing and figuring these things out, and almost always had to revisit the situation due to bug reports coming in just after the publishment.
  • niemo 2009-06-03 19:19
    I've seen the VS 2005 debugger skip over End If, if End If is the last line in a method. The code is otherwise executing fine (as well as an "End If" statement can be executed), it's just a flaw in the debugger. This guy was probably watching the debugger and thought that the line of code was being "skipped".
  • aliquot 2009-06-03 19:28
    I guess you didn't know there is syntax highlighting in vi / vim - here's the first google result for an example

    http://www.cyberciti.biz/faq/turn-on-or-off-color-syntax-highlighting-in-vi-or-vim/

    I have done plenty of coding in vim with syntax highlighting :)

    Or maybe it was SO LONG AGO that you were using a vt100 with a monochrome display, and using "screen" to shift between your vi and debugger "windows" ? ;-)

    captcha: "dolor", suitable comment on going back to vi + debugger after using an ide!
  • Tim williscroft 2009-06-04 04:05
    Once upon a time I ran into a very similarly weird bug in the VMS C compiler.

    I had an extra semicolon between declarations.

    The next FOR loop in the program had the semicolon as it's block.
    The block following was executed just once.

    University assignment. I Did work it: after submitting the (not working, with a complaint) assignment.

  • kc 2009-06-04 16:35
    I prefer to style my comments like this:

    int x = 1;
    /*++++++++++++++++++++++++++++++++++++++++++++++++++++++\
    ++x;/* This is a long comment of a lot of text that * \
    ++x;/* had absolutely no redeeming value except that * \
    ++x;/* it could easily mislead you into making */
    ++x;/* your eye skip right past the relevant part in * /
    ++x;/* the middle of the block of unending comments. * /
    ++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  • Still Not Tim 2009-06-10 07:38
    On the subject of syntax colouring:

    I'm sure I'm not the only one to have experienced the following, when coding in an IDE featuring auto syntax colouring:

    Someone loudly and repeatedly proclaiming that I was "not a real programmer" because I was "wasting time colouring in the letters." o_o
  • shftw 2009-06-13 21:47
    Syntax highlight FTW?
  • anonymous 2013-03-06 17:01
    Leak:
    Old fart:
    It may be related to a known bug in VB6 that occurs if an in-line If statement is nested in an If / End If block, e.g.:

    If blnCondition1 then
    If blnCondition2 then (do something here on this line
    Else
    (do something else here)
    End If

    The nested If must be accompanied with a corresponding End If to avoid the bug. Don't know how this got past the QA when VB6 was released

    That looks more like a dangling else to me...
    A dangling Else shouldn't be possible in BASIC. Both of the methods listed in the Wikipedia article are in play. The single-line version is not ambiguous because the behavior is supposed to be defined. The multi-line version has End If to avoid ambiguity. Ne'er the two shall meet; unholy marriages of the two shouldn't even be syntactically valid:

    If A Then something
    
    Else elsething

    should result in a syntax error (Else without If).

    As far as the syntax of single-line statements is concerned, Else always applies to the nearest If. For instance:

    If A Then If B Then something Else elsething
    
    If A Then If B Then something Else Else elsething

    These are logically different, and should be parsed as follows:

    If A Then (If B Then something Else elsething) Else nothing
    
    If A Then (If B Then something Else nothing) Else elsething

    The single-line version is supposed to be restricted to a single line, and should always end at the end of it. The next line should under no circumstances be parsed as a continuation of it unless the line continuation operator is used to specifically indicate that it should.