Should unreachable code be considered an error?
Sean Kelly
sean at invisibleduck.org
Fri Aug 19 09:33:30 PDT 2011
On Aug 18, 2011, at 10:29 AM, Nick Sabalausky wrote:
> "Bernard Helyer" <b.helyer at gmail.com> wrote in message
> news:j2ithq$12kd$1 at digitalmars.com...
>> I asked the Ars forums ( http://arstechnica.com/civis/viewtopic.php?
>> f=20&t=1153378&p=21965411 ) and I ask the same of you: should
>> unambiguously unreachable code be an error or a warning? ( see the linked
>> forum post for more details ).
>
> No. That would be a royal pain in the ass during debugging. I expect to be
> able to stick a "return xxxx;" anywhere I want to test something and not
> have the compiler crap out because I didn't deal with the overhead of
> commenting out the rest.
>
> A warning might be nice, though.
A warning if anything. I've never encountered a situation where code was made unreachable by accident. I also get "unreachable code" warnings periodically, for code that is absolutely reachable. I don't want my code to not compile simply because the compiler can't perform adequate flow analysis.
More information about the Digitalmars-d
mailing list