Fixing spurious "statement is not reachable" in template code
Jonathan M Davis via Digitalmars-d
digitalmars-d at puremagic.com
Tue Oct 27 10:23:19 PDT 2015
On Tuesday, 27 October 2015 at 16:05:31 UTC, tsbockman wrote:
> On Tuesday, 27 October 2015 at 13:23:51 UTC, Timon Gehr wrote:
>> Versions of the same statement in different instantiations are
>> independent. Templates are just a restricted form of hygienic
>> macros.
>
> That's how the current implementation works, but that doesn't
> mean the warning is actually *helpful*.
Well, arguably that's exactly what templates _are_ regardless of
the implementation - i.e. a template is just a template to
generate code, not really actual code in and of itself. Now, that
being said, I'm not sure that warning about unreachable code in a
templated function is particularly helpful - particularly if it
forces you to jump through hoops to make the compiler shut up
about it. Heck, if anything, I find that warning/error annoying
in regular code, because it tends to get in the way of debugging
while developing. It wouldn't really hurt my feelings any if we
just removed it from the compiler entirely - though I completely
agree that you don't really want to have unreachable code left in
your production code.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list