[dmd-internals] Errors emitted by the optimizer and the as-if rule

Iain Buclaw ibuclaw at ubuntu.com
Mon Aug 20 11:19:14 PDT 2012


On 19 August 2012 10:34, Marco Leise <Marco.Leise at gmx.de> wrote:
> Am 19.08.2012, 10:25 Uhr, schrieb Iain Buclaw <ibuclaw at ubuntu.com>:
>
>
>> 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.
>
>
> What does static add to the mix?
>
> ---- b.d ----
> static foo() {
>     ...
> }
> ---- a.d ----
> import b;
> void main() {
>     foo();
> }
>
> Compiled as separate objects, b.foo can still be linked against.
>

I consider static functions local only to the current compilation
unit.  It is not a global/public decl that can have it's reference
pulled in from an external object / library.


-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


More information about the dmd-internals mailing list