Recommendation: Compile DMD with More Warnings

Orvid King blah38621 at gmail.com
Sun Apr 6 09:45:29 PDT 2014


On Sunday, 6 April 2014 at 16:27:50 UTC, Andrei Alexandrescu 
wrote:
> On 4/6/14, 2:49 AM, "Nordlöw" wrote:
>> I recommend the lead developers of DMD to look into activating 
>> more
>> warnings in the dmd/src/posix.mak.
>>
>> GCC 4.8.2 and especially Clang 3.4, both prepackage on Ubuntu
>> 13.10/14.04 give a *lot* of warnings that seems to indicate 
>> potential
>> bugs in the DMD source code.
>>
>> This setting gives useful warnings and at the same time avoid 
>> the
>> annoying ones
>>
>> WARNINGS=-Wall -Wextra -Wno-deprecated -Wstrict-aliasing
>> -Wno-unused-parameter -Wno-unused-variable -Wunused-function
>> -Wno-unused-label -Wno-unknown-pragmas -Wno-sign-compare
>> -Wno-overloaded-virtual -Wno-missing-braces
>> -Wno-missing-field-initializers -Wno-logical-op-parentheses
>>
>> For example there a *lot* of -Wsometimes-uninitialized which 
>> IMHO seems
>> like the most dangereous ones. This one is however Clang 
>> specific but I
>> have not had any problems running a Clang compiled version of 
>> DMD.
>> Further Clang compiles DMD about twices as fast as GCC. Good 
>> work
>> developers on disabling use of STL in DMD!
>>
>> I can do a pull request if desired for the posix.make update 
>> if wanted.
>
> I'm not a regular core dmd dev but I'm already seeing warnings 
> with clang on OSX and I think fixing them would be beneficial. 
> I'd support a pull request. In all likelihood it would also 
> need to fix the warnings themselves, so you may want to enable 
> only a few warnings at a time so as to keep the pull request 
> sizes manageable. -- Andrei

If you want, I have the results of a static analysis of DMD that 
I could post, as processed in 23 hours and 58 minutes by Intel's 
C compiler, using 10gb of RAM the entire time. If I can figure 
out how to have it not skip any methods (there were still a 
significant number that it didn't analyze due to complexity 
limits) I'll run it again and post the full results. In my basic 
look over the results, there were a decent number of them that 
may actually be bugs. (buffer overruns, and even a few instances 
of accessing memory after it had been freed)

On the topic of actual warnings, I would be careful with them, 
because compiling DMD with MSVC with the maximum warning level 
(essentially -Wall), it produces 150k lines of output, most of 
them about stuff being inlined, and quite a bit of other stuff 
that you quite simply, don't care about.


More information about the Digitalmars-d mailing list