D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5137 - Compiler tips
Summary: Compiler tips
Status: RESOLVED DUPLICATE of issue 5051
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-30 15:19 UTC by bearophile_hugs
Modified: 2016-10-14 13:36 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2010-10-30 15:19:48 UTC
A third class of compiler messages, beside the warnings and the errors are "tips". They aren't sure errors or possible errors, they are situations where for example the compiler suggests possible performance improvements or where the programmer may add more constraints to the functions.

See bug 5056 , bug 5070

Another example is from a feature added to GCC 4.6:
http://gcc.gnu.org/gcc-4.6/changes.html
http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-Options

-Wsuggest-attribute=pure
-Wsuggest-attribute=const
-Wsuggest-attribute=noreturn

This shows tips where that attribute may be added to the code.

Another example: the compiler may suggest cases where using an Appender may be used instead of many normal array appends.

Another possible compiler tip is to optionally list all points where a very large fixed-sized array is passed by value (see bug 4580 ).
Comment 1 Infiltrator 2015-12-09 10:20:32 UTC
I don't know whether it's necessary to add another class of compiler messages.  It might be enough to just make these warnings.  It would be helpful especially useful for @nogc.
Comment 2 bearophile_hugs 2015-12-09 12:54:02 UTC
(In reply to Infiltrator from comment #1)
> I don't know whether it's necessary to add another class of compiler
> messages.  It might be enough to just make these warnings.  It would be
> helpful especially useful for @nogc.

Warnings are meant to warn you against something. Compiler tips are more like suggestions (but it's not an essential difference, I agree. What's important is to produce some message). The compilers of other good languages have such kind of messages, so they can be good for D too.
Comment 3 Andrei Alexandrescu 2016-10-14 13:36:04 UTC
I'll mark this as a dupe of 5051 because tips could be a part of that tool.

*** This issue has been marked as a duplicate of issue 5051 ***