DMD Source Guidance: Unused Return Values of Strictly Pure Function Calls

"Nordlöw" per.nordlow at gmail.com
Fri Feb 28 02:36:54 PST 2014


I believe I found a good solution to Issue 3882:
https://d.puremagic.com/issues/show_bug.cgi?id=3882

It works as expected and I found two bugs in my code with it.

My current solution is to add the following at line 147 in 
dmd/src/sideeffect.c:

       case TOKcall:
             /* Issue 3882: Don't complain about calling functions 
with no effect,
              * because purity and nothrow are inferred, and 
because some of the
              * runtime library depends on it. Needs more 
investigation.
              */
             if (global.params.warnings && !global.gag)
             {
                 if (e->type->ty == Tvoid)
                 {
                     /* TODO: Restrict this message to call 
hierarchies that
                      * never call assert (and or not called from 
inside
                      * unittest blocks) */
                     // e->warning("Call %s with void return has 
no effect", e->toChars());
                 }
                 else
                 {
                     e->warning("Call %s with no effect discards 
return value", e->toChars());
                 }
             }
             return;

Does it suffice to just do a pull request referring to Issue 3882.

/Per


More information about the Digitalmars-d-learn mailing list