[Issue 17424] New: Add useful warnings

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue May 23 17:16:18 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17424

          Issue ID: 17424
           Summary: Add useful warnings
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P3
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: eyal at weka.io

I have debugged many bugs for many hours that would have been caught by a
simple warning in C or C++.

Here are a few warnings I'd really like to see when building D code.

* Unused parameter -- of course you should be able to say "intentionally
unused" (underscore prefix to name? a uda?)

* Unused imports -- this is super important to keep incremental compile times
down

* Copying a large value (more than given threshold) - when passing parameters,
in assignments, etc. Can always use explicit copy functions instead, pass by
ref, etc.

* Allocating a large value on the stack (more than given threshold) - very
useful for fibers with small stacks.

* Unused definitions/types: a function is not reachable by any non-private
definition -- some uda should allow overriding this

* Signed/unsigned comparisons

* Function is @nogc but not marked as such

* Function is pure but not marked as such

* Function is nothrow but not marked as such

* Function is const but not marked as such

* Code was determined to be dead (will never be executed)

* Use of implicitly initialized variable (for variables implicitly set to
.init), at least for floats/doubles where NaN is likely to be bug-prone.

* Use of voided variable (for variables init'd with =void)

* Constructor may throw - no automatic destruction will occur

* Conditional used is always true/false and compiled out -- must be able to
wash away known-good instances

It doesn't matter if they are opt-in warnings, opt-out/always errors, or a
separate compiler-library thing -- but ideally I wouldn't need to run all the
CTFE twice just to get my warnings.

--


More information about the Digitalmars-d-bugs mailing list