Unreachable code detected?
-
Jasmine2501, Try it out and see what happens, but why would you want something like this to be compiled? If you have code that is unreachable you might as well just hit the delete key on it. Regards, Gareth.
Yes exactly, but I'm interested in proving that it results in no-codez - because I'm hitting the delete key on someone else's stuff and they swear the compiler warning is just something to be ignored.
"Quality Software since 1983!"
http://www.smoothjazzy.com/ - see the "Programming" section for freeware tools and articles. -
Yes exactly, but I'm interested in proving that it results in no-codez - because I'm hitting the delete key on someone else's stuff and they swear the compiler warning is just something to be ignored.
"Quality Software since 1983!"
http://www.smoothjazzy.com/ - see the "Programming" section for freeware tools and articles.I believe it can be ignored as much as it warns you for unassigned variables etc, but if you want to modify someone else's code, how about commenting out segments you wish to change, or better yet just clone the project and play with it to your heart's content.
He who makes a beast out of himself gets rid of the pain of being a man
-
When the compiler gives this warning, does the code actually compile? Is any MSIL generated for the code that is unreachable?
"Quality Software since 1983!"
http://www.smoothjazzy.com/ - see the "Programming" section for freeware tools and articles.Yes and no. A switch statement with a return immediately before a break. The break is unreachable so is not compiled into IL.
Deja View - the feeling that you've seen this post before.
-
Yes exactly, but I'm interested in proving that it results in no-codez - because I'm hitting the delete key on someone else's stuff and they swear the compiler warning is just something to be ignored.
"Quality Software since 1983!"
http://www.smoothjazzy.com/ - see the "Programming" section for freeware tools and articles.Hi, I use
#if false
and#endif
for hiding code. :)Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
-
When the compiler gives this warning, does the code actually compile? Is any MSIL generated for the code that is unreachable?
"Quality Software since 1983!"
http://www.smoothjazzy.com/ - see the "Programming" section for freeware tools and articles.No, there isn't - which I'm a bit surprised about. Makes no sense to include unreachable code I guess. Confirmed via Reflector/ildasm.
Regards, Rob Philpott.
-
I believe it can be ignored as much as it warns you for unassigned variables etc, but if you want to modify someone else's code, how about commenting out segments you wish to change, or better yet just clone the project and play with it to your heart's content.
He who makes a beast out of himself gets rid of the pain of being a man
Well I'm working in a company environment... anything I do has to integrate with everything else. This is a super-large project. It takes Visual Studio literally 5 minutes to compile the site and all the DLLs and everything. I'm optimizing things, and I do have free reign on the code at the moment, but I do have to justify what I do sometimes. I realize that the warnings don't prevent the thing from working, but they are not be ignored. One of my mentors always said "warnings are like a sign saying the bridge is out - it won't keep you from going down the road, but there's gonna be trouble eventually"
"Quality Software since 1983!"
http://www.smoothjazzy.com/ - see the "Programming" section for freeware tools and articles. -
When the compiler gives this warning, does the code actually compile? Is any MSIL generated for the code that is unreachable?
"Quality Software since 1983!"
http://www.smoothjazzy.com/ - see the "Programming" section for freeware tools and articles.Just be sure it's not the result of conditional compilation. Though even then it should be written so as not to produce a warning.
-
Yes and no. A switch statement with a return immediately before a break. The break is unreachable so is not compiled into IL.
Deja View - the feeling that you've seen this post before.
:cool:
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
-
Just be sure it's not the result of conditional compilation. Though even then it should be written so as not to produce a warning.
Yes, our site originally had over 100 compiler warnings when you build. I consider that a Bad Thing. I've got it down to 23 at the moment, but I want to get it down to zero. Warnings are the computer telling you that something stupid is going on, not a broken something stupid, but still something stupid, and in most cases you just delete the thing, or code it a different way and it's functionally equivalent, but doesn't cause the warning. The break after a return statement is a good example... not having the break eliminates the warning, the break isn't necessary, and it's probably just there because somebody was told to put breaks in their switch/case blocks and was never told what it actually does.
"Quality Software since 1983!"
http://www.smoothjazzy.com/ - see the "Programming" section for freeware tools and articles. -
Use ILDasm on your assembly to find out. Very nifty tool. Scott
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
carbon_golem wrote:
Use ILDasm on your assembly to find out. Very nifty tool.
I second that.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon