Should unreachable code be considered an error?
Stewart Gordon
smjg_1998 at yahoo.com
Mon Aug 22 14:27:39 PDT 2011
On 20/08/2011 07:28, Bernard Helyer wrote:
> On Sat, 20 Aug 2011 01:42:56 +0100, Stewart Gordon wrote:
>
>> So essentially you're looking to catch cases where, if you consider the
>> function as a flow chart, there is no chain of arrows from the start of
>> the function to the statement in question. That should be
>> straightforward. But you're not worrying about catching cases where
>> some arrow would never be followed. Have I got that right?
>
> Pretty much, minor correction on the last part -- an arrow means that the
> compiler considers it a possibility, so it's not considered in so far as
> the data structure doesn't make the distinction.
That's more or less what I meant. The compiler can't identify all arrows that will never
be followed - this would mean solving the halting problem. So it takes the view that any
arrow _may_ be followed. But if there's no arrow at all leading to a statement, the
compiler can easily see that it's unreachable and so issue a warning/error.
Stewart.
More information about the Digitalmars-d
mailing list