• Post Reply Bookmark Topic Watch Topic
  • New Topic

Whinge: most frustrating bug ever...  RSS feed

 
Tim West
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Way to start a Monday. I just took two hours to find a problem in my code...it came down to the following code:



Spot the infinite loop What other nasties have people seen?

In my defence I had written a lot more code than just these lines...yes, testing more frequently is a Good Thing (TM) but (insert ranting excuse here)

-Tim
[ June 20, 2004: Message edited by: Tim West ]
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, that one hurts. Interestingly enough, though, the latest generation of tools, together with using the (*cough*) correct code formatting standard, won't let you make this mistake anymore. If you accidentally write



then IntelliJ IDEA will insist on formatting it as



with the brace on the next line instead of in the right place -- which, if you're used to working with the tools, will immediately tip you off that something is wrong.
 
Tim West
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, guess I better resist the urge to start either a brace-war or an IDE war . Then again, I guess I could change my opinion on braces if someone were to give me a copy of IDEA...I could be bought pretty cheap.

I'm surprised Eclipse doesn't have a warning for that sort of thing. Guess they figure most people are too smart to make that mistake.

Still, lesson learned: don't be an idiot! And maybe become an Eclipse developer so I can fix this sorta thing. Or not.


--Tim
[ June 20, 2004: Message edited by: Tim West ]
 
Warren Dew
blacksmith
Ranch Hand
Posts: 1332
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think some IDEs/compilers avoid warning on that because sometimes people might actually want an infinite loop.

The compiler I use warns on it unless you put the semicolon on a separate line, which seems a pretty good compromise.
 
Tim West
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fair enough. Eclipse has a good selection of warnings, and you can set each to report at levels "Ignore", "Warning" or "Error" as desired.

The warnings include such relatively mundane things as "uncommented empty block" so I thought it might include this one too.



--Tim
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!