|
You have to try to do nothing with so much code.
Last post 11-06-2007 1:03 PM by Thief^. 37 replies.
-
11-01-2007 3:54 PM
|
|
-
djork


- Joined on 09-28-2006
- Posts 634
|
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."
|
|
-
-
-
Renan "C#" Sousa


- Joined on 08-10-2007
- Fortaleza, Brazil
- Posts 218
|
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
|
|
-
-
Random832


- Joined on 05-09-2007
- Posts 434
|
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?
|
|
-
-
MasterPlanSoftware


- Joined on 11-10-2006
- Posts 10
|
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.
|
|
-
-
Random832


- Joined on 05-09-2007
- Posts 434
|
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?
|
|
-
-
joe.edwards


- Joined on 08-14-2006
- Dallas, TX
- Posts 226
|
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.
|
|
-
-
Quinnum


- Joined on 05-27-2005
- Posts 225
|
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.
|
|
-
-
Otterdam


- Joined on 09-25-2006
- Posts 110
|
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...
|
|
-
-
bobday


- 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
|
|
-
-
jcoehoorn


- Joined on 06-21-2007
- Posts 56
|
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?
|
|
-
-
djork


- Joined on 09-28-2006
- Posts 634
|
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."
|
|
-
-
DaveK


- Joined on 02-22-2006
- Posts 398
|
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?
|
|
-
-
DaveK


- Joined on 02-22-2006
- Posts 398
|
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?
|
|
-
-
Quinnum


- Joined on 05-27-2005
- Posts 225
|
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.
|
|
-
-
TunnelRat


- Joined on 11-30-2006
- Posts 124
|
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.
|
|
-
-
MasterPlanSoftware


- Joined on 11-10-2006
- Posts 10
|
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.
|
|
-
-
PSWorx


- Joined on 04-28-2006
- Posts 682
|
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 }
|
|
-
-
m0ffx


- Joined on 08-15-2006
- Posts 560
|
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
|
|
-
-
ammoQ


- 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
|
|
-
-
PSWorx


- Joined on 04-28-2006
- Posts 682
|
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() {
}
|
|
-
-
aib


- 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.
|
|
-
-
PJH


- 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.
|
|
-
-
PSWorx


- Joined on 04-28-2006
- Posts 682
|
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(); }
?
|
|
-
|
|