Should unreachable code be considered an error?

maarten van damme maartenvd1994 at gmail.com
Fri Aug 19 08:30:57 PDT 2011


Why not a warning but when compiling using the -release flag throw an error?
Sounds logical to me as unreachable code can be there because of
debugging,etc but any released executable should not contain unreachable
code.

2011/8/18 Don <nospam at nospam.com>

> Timon Gehr wrote:
>
>> On 08/18/2011 02:38 PM, Bernard Helyer wrote:
>>
>>> Faramir on the Ars forums makes an excellent point:
>>>
>>> "With the c preprocessor, both theoretically and as it is used in
>>> practice, you can easily get dead code in certain compile paths that is
>>> live in others."
>>>
>>> I think template mixins can achieve the same sort of shenanigans. I think
>>> warning it is.
>>>
>>
>> You mean string mixins?
>> As string mixins are so much more expressive than C macros, one should
>> actually almost never get trivial dead code in well designed string mixins.
>>
>
> Yes, the equivalent to the C preprocessor is version statements.
> Obviously anything wrapped in a version(none) block shouldn't generate an
> "unreachable code" error...
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20110819/695bfcf6/attachment.html>


More information about the Digitalmars-d mailing list