[dmd-internals] Errors emitted by the optimizer and the as-if rule
code at klickverbot.at
Mon Aug 20 11:29:05 PDT 2012
On 19 Aug 2012, at 10:25, Iain Buclaw wrote:
> You can only be certain that a function is never invoked unless it is
> marked 'static' IMO. My opinion is that it should warn you anyway, as
> it is potentially buggy code, even if unused.
Yes, sure, emitting a warning is fine, even more so if the code is
known to be live.
My point about foo being unused is that DMD emits a hard error for a
piece of code which is perfectly to spec (the example snipped for
VoidInitializer even shows a similar case) and doesn't exhibit
Either cases like this should be made illegal, implying that alternate
compiler are allowed to perform the check in the frontend (checking
for this during codegen can only be described as a hack, even if it is
more or less zero-cost that way), or DMD should stop to emit an error.
Things like this actually do hurt compatibility across compilers (as
nobody is going to implement the check like DMD does) - I once ran
into a similar case with Thrift, where DMD complained about a null
pointer dereference in dead code.
More information about the dmd-internals