The Daily WTF: Curious Perversions in Information Technology
Welcome to TDWTF Forums Sign in | Join | Help
in Search

You have to try to do nothing with so much code.

Last post 11-06-2007 1:03 PM by Thief^. 37 replies.
Page 1 of 1 (38 items)
Sort Posts: Previous Next
  • 11-01-2007 3:54 PM

    You have to try to do nothing with so much code.

    This is actually, for real, totally serious, not joking, straight code from our production application. Absolutely nothing was changed in this snippet.

    Try
    
    Catch ex As Exception
        Throw ex
    
    Finally
    
    End Try
    
    "Frames securely mediate, by design. Secure multi-mediation is the future of all webbing."
  • 11-01-2007 4:04 PM In reply to

    • purge
    • Top 500 Contributor
    • Joined on 08-16-2007
    • Posts 74

    Re: You have to try to do nothing with so much code.

    Try

    Catch ex As SpontaneousException
    Throw ex

    Finally

    End Try
    Filed under:
  • 11-01-2007 4:17 PM In reply to

    Re: You have to try to do nothing with so much code.

    SpontaneousException made me crack out lout in the office.
    Code Monkey like Fritos
    Code Monkey like Tab and Mountain Dew
    Code Monkey very simple man
    with big warm fuzzy secret heart
    Code Monkey like you
    Code Monkey like you a lot
  • 11-01-2007 4:30 PM In reply to

    Re: You have to try to do nothing with so much code.

    djork:

    This is actually, for real, totally serious, not joking, straight code from our production application. Absolutely nothing was changed in this snippet.

    Try
    
    Catch ex As Exception
        Throw ex
    
    Finally
    
    End Try
    

    So... the WTF is that they didn’t just re-throw with “Throw”, right?

  • 11-01-2007 4:32 PM In reply to

    Re: You have to try to do nothing with so much code.

    Random832:
    djork:

    This is actually, for real, totally serious, not joking, straight code from our production application. Absolutely nothing was changed in this snippet.

    TryCatch ex As Exception    Throw exFinallyEnd Try

    So... the WTF is that they didn’t just re-throw with “Throw”, right?

     

    How about the fact there is NO code inside the Try block? 

    Yes, I have been banned. Thanks to all for a good time.

    Tired of incompetent moderation?
    Wondering where all the clever discussion went?
    Try irc.slashnet.org #TDWTFMafia.
    We don't ban or kick and everyone is welcome.*

    *Stupid people will be mocked mercilessly and encouraged to commit suicide, however.
  • 11-01-2007 4:51 PM In reply to

    Re: You have to try to do nothing with so much code.

    MasterPlanSoftware:
    Random832:
    djork:

    This is actually, for real, totally serious, not joking, straight code from our production application. Absolutely nothing was changed in this snippet.

    TryCatch ex As Exception    Throw exFinallyEnd Try

    So... the WTF is that they didn’t just re-throw with “Throw”, right?

    How about the fact there is NO code inside the Try block?

  • 11-01-2007 5:04 PM In reply to

    Re: You have to try to do nothing with so much code.

    Random832:
    djork:

    This is actually, for real, totally serious, not joking, straight code from our production application. Absolutely nothing was changed in this snippet.

    Try
    
    Catch ex As Exception
        Throw ex
    
    Finally
    
    End Try
    

    So... the WTF is that they didn’t just re-throw with “Throw”, right?

    No, the WTF is that it's in VB.</obligatory>

    Actually, I've seen this many times in boilerplate templates, which assume you are going to write something inside the try block.  So, actually, yes; the most WTF part is that they don't re-throw properly.

  • 11-01-2007 5:58 PM In reply to

    Re: You have to try to do nothing with so much code.

    joe.edwards@imaginuity.com:
    Random832:
    djork:

    This is actually, for real, totally serious, not joking, straight code from our production application. Absolutely nothing was changed in this snippet.

    Try

    Catch ex As Exception
    Throw ex

    Finally

    End Try

    So... the WTF is that they didn’t just re-throw with “Throw”, right?

    No, the WTF is that it's in VB.</obligatory>

    Actually, I've seen this many times in boilerplate templates, which assume you are going to write something inside the try block.  So, actually, yes; the most WTF part is that they don't re-throw properly.

    I agree. Looks like somebody just inserted a snippet on Visual Studio meaning to do something there, then forgot to take it out.


  • 11-01-2007 9:21 PM In reply to

    Re: You have to try to do nothing with so much code.

    I'm more surprised the 'whoosh' tag hasn't been used before. I was expecting as many posts as there are sidebar WTFs...
    Filed under:
  • 11-01-2007 11:32 PM In reply to

    • bobday
    • Top 150 Contributor
    • Joined on 04-04-2005
    • Notbugville
    • Posts 175

    Re: You have to try to do nothing with so much code.

    djork:

    This is actually, for real, totally serious, not joking, straight code from our production application. Absolutely nothing was changed in this snippet.

    Try

    Catch ex As Exception
    Throw ex

    Finally

    End Try

     Widely-believed fact: In cases like this, the CLR inserts a "throw" instruction out of spite
     

  • 11-02-2007 10:49 AM In reply to

    Re: You have to try to do nothing with so much code.

    Let's have a little contest:  Who can write the most code that will compile to no instructions?
  • 11-02-2007 10:55 AM In reply to

    Re: You have to try to do nothing with so much code.

    jcoehoorn:
    Let's have a little contest:  Who can write the most code that will compile to no instructions?

    Excellent WTF coding challenge right there.  Comments don't count, and no repeating.  I think C might be a good place to start, with the help of GCC's optimization options. 

    "Frames securely mediate, by design. Secure multi-mediation is the future of all webbing."
  • 11-02-2007 11:00 AM In reply to

    Re: You have to try to do nothing with so much code.

    MasterPlanSoftware:
    Random832:
    djork:

    This is actually, for real, totally serious, not joking, straight code from our production application. Absolutely nothing was changed in this snippet.

    TryCatch ex As Exception    Throw exFinallyEnd Try

    So... the WTF is that they didn’t just re-throw with “Throw”, right?

     

    How about the fact there is NO code inside the Try block?

    Are you implying it would be OK if there was also no code inside the Catch block?

  • 11-02-2007 11:02 AM In reply to

    Re: You have to try to do nothing with so much code.

    MasterPlanSoftware:
    Random832:
    djork:

    This is actually, for real, totally serious, not joking, straight code from our production application. Absolutely nothing was changed in this snippet.

    TryCatch ex As Exception    Throw exFinallyEnd Try

    So... the WTF is that they didn’t just re-throw with “Throw”, right?

     

    How about the fact there is NO code inside the Try block?

    But what if the no code inside the Try block was using an sNOP instead of a qNOP?

     

  • 11-02-2007 9:32 PM In reply to

    Re: You have to try to do nothing with so much code.

    DaveK:
    MasterPlanSoftware:
    Random832:
    djork:

    This is actually, for real, totally serious, not joking, straight code from our production application. Absolutely nothing was changed in this snippet.

    TryCatch ex As Exception    Throw exFinallyEnd Try

    So... the WTF is that they didn’t just re-throw with “Throw”, right?

     

    How about the fact there is NO code inside the Try block?

    Are you implying it would be OK if there was also no code inside the Catch block?

    Only if you subscribe to the "On Error Resume Next" pattern.

     

  • 11-03-2007 12:11 AM In reply to

    Re: You have to try to do nothing with so much code.

    djork:

    This is actually, for real, totally serious, not joking, straight code from our production application. Absolutely nothing was changed in this snippet.

    Try
    
    Catch ex As Exception
        Throw ex
    
    Finally
    
    End Try
    

    This is no big deal.  I use CodeRush and it stubs out a bunch of code for me.  If I'm rockin', like if I'm in the zone, I'll type "tc" and BAMB!  There is my try-catch-block all ready to go.  And sometimes I won't refactor as well as I should, and leave this stuff around.  That is, when I'm not unemployed.

    So I have say that this is not a WTF.  Nothing personal.

    Filed under:
  • 11-03-2007 10:36 AM In reply to

    Re: You have to try to do nothing with so much code.

    TunnelRat:
    djork:

    This is actually, for real, totally serious, not joking, straight code from our production application. Absolutely nothing was changed in this snippet.

    TryCatch ex As Exception    Throw exFinallyEnd Try

    This is no big deal.  I use CodeRush and it stubs out a bunch of code for me.  If I'm rockin', like if I'm in the zone, I'll type "tc" and BAMB!  There is my try-catch-block all ready to go.  And sometimes I won't refactor as well as I should, and leave this stuff around.  That is, when I'm not unemployed.

    So I have say that this is not a WTF.  Nothing personal.

    So you leave stubs that eliminate the stack during an exception all over your code?

     Brilliant!

    Yes, I have been banned. Thanks to all for a good time.

    Tired of incompetent moderation?
    Wondering where all the clever discussion went?
    Try irc.slashnet.org #TDWTFMafia.
    We don't ban or kick and everyone is welcome.*

    *Stupid people will be mocked mercilessly and encouraged to commit suicide, however.
  • 11-03-2007 2:31 PM In reply to

    Re: You have to try to do nothing with so much code.

    djork:

    jcoehoorn:
    Let's have a little contest:  Who can write the most code that will compile to no instructions?

    Excellent WTF coding challenge right there.  Comments don't count, and no repeating.  I think C might be a good place to start, with the help of GCC's optimization options. 

    Wouldn't that be a rather easy challange?

    if (false) {
        // Insert arbitrary amounts of code here
    }
     

  • 11-03-2007 10:17 PM In reply to

    Re: You have to try to do nothing with so much code.

    If that's the extent of the program, will the compiler allow it to compile to no instructions?

    Also, I'm sure there'd be some hideous means to get the code in such a block to execute. Don't know what mind. 

    TRWTF is Community Server
  • 11-04-2007 7:37 AM In reply to

    • ammoQ
    • Top 10 Contributor
    • Joined on 04-13-2005
    • Vienna.Austria.Europe.Earth
    • Posts 3,291

    Re: You have to try to do nothing with so much code.

    m0ffx:

    If that's the extent of the program, will the compiler allow it to compile to no instructions?

    I think so. At least the object files are of the same size....

    [erich@iTux ~]$ cat test1.c
    #include <stdio.h>
    int nix() {
            if (0) {
                    printf("Nix");
            }
    }
    [erich@iTux ~]$ cat test2.c
    #include <stdio.h>
    int nix() {
    }
    [erich@iTux ~]$ cc -c test1.c
    [erich@iTux ~]$ cc -c test2.c
    [erich@iTux ~]$ ls -l test1.o test2.o
    -rw-r--r-- 1 erich erich 685 Nov  4 13:35 test1.o
    -rw-r--r-- 1 erich erich 685 Nov  4 13:35 test2.o
    [erich@iTux ~]$


     

    beanbag girl 4ever
  • 11-04-2007 8:47 AM In reply to

    Re: You have to try to do nothing with so much code.

    m0ffx:

    If that's the extent of the program, will the compiler allow it to compile to no instructions?

    Also, I'm sure there'd be some hideous means to get the code in such a block to execute. Don't know what mind. 

    At least SpiderMonkey, Mozilla's JS compiler/interpreter does it for JavaScript. Because it also includes a decompiler, it can easily be seen:

    function f() {
        if (0) {
           alert("foo");
        }
    }
    
    alert(f.toString());
    
    shows
    function f() {
    }
    
  • 11-04-2007 12:38 PM In reply to

    • aib
    • Top 500 Contributor
    • Joined on 01-03-2007
    • Posts 87

    Re: You have to try to do nothing with so much code.

    m0ffx:

    If that's the extent of the program, will the compiler allow it to compile to no instructions?

    Also, I'm sure there'd be some hideous means to get the code in such a block to execute. Don't know what mind. 

    if (0) {

       label: printf("oh noes!");

    }

    goto label;

     

    Since even "unreachable code"s compile into the object file (on my compiler anyway), we need something the optimizer would throw away. How about:

    int i;

    for(i=0; i<10; i++);

    for(i=0; i<10; i++);

    (repeat as many times as you'd like)

    I may or may not have meant what I've said above.
  • 11-04-2007 12:53 PM In reply to

    • PJH
    • Top 25 Contributor
    • Joined on 02-14-2007
    • Posts 596

    Re: You have to try to do nothing with so much code.

    aib:

    Since even "unreachable code"s compile into the object file (on my compiler anyway), we need something the optimizer would throw away. How about:

    int i;

    for(i=0; i<10; i++);

    for(i=0; i<10; i++);

    (repeat as many times as you'd like)

    One of the addendums to the rules specified no repetition.

    This is not a problem that requires infinite wisdom, Benj. This is a problem that requires enough neural organization to qualify as a vertebrate, apparently a stretch for some folks these days.
    - Cecil Adams.
  • 11-04-2007 1:12 PM In reply to

    Re: You have to try to do nothing with so much code.

    PJH:

    aib:

    Since even "unreachable code"s compile into the object file (on my compiler anyway), we need something the optimizer would throw away. How about:

    int i;

    for(i=0; i<10; i++);

    for(i=0; i<10; i++);

    (repeat as many times as you'd like)

    One of the addendums to the rules specified no repetition.

    Besides, i++ is an instruction. And since i is being read in i<10, no optimizer could throw away that instruction either.

    How about

    inline int foo() {
        // lots of code
    }

    int main() {
        return 1 ? 0 : foo();
    }

  • 11-04-2007 1:22 PM In reply to

    Re: You have to try to do nothing with so much code.