www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Recommendation: Compile DMD with More Warnings

reply =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
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.
Apr 06 2014
next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
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
Apr 06 2014
parent reply "Orvid King" <blah38621 gmail.com> writes:
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.
Apr 06 2014
next sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
Orvid King:

 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.
I'd like dmd/ldc2 compilers to compile with warnings active on default, plus to have a switch to disable them. Bye, bearophile
Apr 06 2014
next sibling parent reply =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
On Sunday, 6 April 2014 at 17:39:38 UTC, bearophile wrote:
 Orvid King:

 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.
I'd like dmd/ldc2 compilers to compile with warnings active on default, plus to have a switch to disable them. Bye, bearophile
Could you give me a priority list of the typical warning types sorted an descending severity? /Per
Apr 06 2014
parent reply "bearophile" <bearophileHUGS lycos.com> writes:
Nordlöw:

 Could you give me a priority list of the typical warning types 
 sorted an descending severity?
I can't, I don't understand your question, and I don't understand why you want such list. Bye, bearophile
Apr 06 2014
parent =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
 I can't, I don't understand your question, and I don't 
 understand why you want such list.
Just so I know where I should begin digging ;)
Apr 06 2014
prev sibling parent reply "David Nadlinger" <code klickverbot.at> writes:
On Sunday, 6 April 2014 at 17:39:38 UTC, bearophile wrote:
 I'd like dmd/ldc2 compilers to compile with warnings active on 
 default, plus to have a switch to disable them.
LDC is actually built with -Wall -Wextra by default. The warnings are disabled for the DMD source files though, as leaving them on just floods the console output, making actual issues much harder to see. We will have to look into additionally adding warning push/pop pragmas around the frontend includes in the "proper" LDC source files though. Currently, we get quite a bit of log spam from them, and some of them are unlikely to be addressed in the upstream source. David
Apr 06 2014
parent Iain Buclaw <ibuclaw gdcproject.org> writes:
On 6 Apr 2014 21:15, "David Nadlinger" <code klickverbot.at> wrote:
 On Sunday, 6 April 2014 at 17:39:38 UTC, bearophile wrote:
 I'd like dmd/ldc2 compilers to compile with warnings active on default,
plus to have a switch to disable them.
 LDC is actually built with -Wall -Wextra by default. The warnings are
disabled for the DMD source files though, as leaving them on just floods the console output, making actual issues much harder to see.
 We will have to look into additionally adding warning push/pop pragmas
around the frontend includes in the "proper" LDC source files though. Currently, we get quite a bit of log spam from them, and some of them are unlikely to be addressed in the upstream source.

You should have more abstraction in LDC between the two frontend layers. :)
Apr 06 2014
prev sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/6/2014 9:45 AM, Orvid King wrote:
 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)
Yes, please post.
Apr 06 2014
parent Brad Roberts <braddr puremagic.com> writes:
On 4/6/14, 10:38 PM, Walter Bright wrote:
 On 4/6/2014 9:45 AM, Orvid King wrote:
 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)
Yes, please post.
... to bugzilla.
Apr 07 2014
prev sibling next sibling parent reply "Suliman" <evermind live.ru> writes:
Who could explain. AFAIK D was position as language without 
warnings. The idea was in that code maybe correct or wrong, 
without any intermediate state, and now I am reading about 
warnings.
Apr 06 2014
parent Iain Buclaw <ibuclaw gdcproject.org> writes:
On 7 Apr 2014 06:20, "Suliman" <evermind live.ru> wrote:
 Who could explain. AFAIK D was position as language without warnings. The
idea was in that code maybe correct or wrong, without any intermediate state, and now I am reading about warnings. This thread is talking about the compiler implementation (written in C++). As for D's stance on warnings, it's pretty much only used for features being removed, as part of our deprecate/warn/error process. Code that is considered incorrect is always an error.
Apr 06 2014
prev sibling next sibling parent reply "Daniel Murphy" <yebbliesnospam gmail.com> writes:
""Nordlöw""  wrote in message news:qjwcprwdvrwyvrbftnto forum.dlang.org...

 I can do a pull request if desired for the posix.make update if wanted.
Don't forget we'll soon be switching away from gcc/clang/msvc for compiling the frontend.
Apr 07 2014
next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
Daniel Murphy:

 Don't forget we'll soon be switching away from gcc/clang/msvc 
 for compiling the frontend.
So performing some static analysis before the switch looks like a good idea to make the switch smoother and safer. Also because the static analysis tools for the D code are much less good. Bye, bearophile
Apr 07 2014
prev sibling parent reply =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
 Don't forget we'll soon be switching away from gcc/clang/msvc 
 for compiling the frontend.
To compiling it with DMD!?
Apr 07 2014
parent reply "Daniel Murphy" <yebbliesnospam gmail.com> writes:
""Nordlöw""  wrote in message news:ysueyapbcgrupyrikmhq forum.dlang.org...

 Don't forget we'll soon be switching away from gcc/clang/msvc for 
 compiling the frontend.
To compiling it with DMD!?
Exactly! https://github.com/D-Programming-Language/dmd/pull/3410
Apr 07 2014
parent reply =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
 https://github.com/D-Programming-Language/dmd/pull/3410
How soon will this happen? What kind of D style programming will DDMD enable not possible in C++? Will it for example make use of array slicing?
Apr 07 2014
parent "Daniel Murphy" <yebbliesnospam gmail.com> writes:
 ""Nordlöw""  wrote in message news:obdtzcdsjzjzttjkpjxf forum.dlang.org...
 https://github.com/D-Programming-Language/dmd/pull/3410
How soon will this happen?
Hopefully in the next few months.
 What kind of D style programming will DDMD enable not possible in C++?
None, initially. It currently produces D code almost identical to the C++ code. Once development has switched over, we can go through and start refactoring it to use foreach, ranges, delegates, etc
 Will it for example make use of array slicing?
Most likely.
Apr 07 2014
prev sibling parent reply "asman" <lol.themask gmail.com> writes:
On Sunday, 6 April 2014 at 09:49:59 UTC, 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.
Could be great too if someone run a static analyzer like on dmd code http://www.cppcat.com I'll try when I back to Windows
Apr 07 2014
next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
asman:

 Could be great too if someone run a static analyzer like on dmd
 code http://www.cppcat.com I'll try when I back to Windows
This was done some time ago (with the big brother of CppCat). Bye, bearophile
Apr 07 2014
prev sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/7/2014 6:48 AM, asman wrote:
 Could be great too if someone run a static analyzer like on dmd
 code http://www.cppcat.com I'll try when I back to Windows
The static analyzer PVS-Studio was run on dmd last year. It found 2 bugs, and several thousand false positives.
Apr 07 2014
parent reply "Orvid King" <blah38621 gmail.com> writes:
On Monday, 7 April 2014 at 17:05:46 UTC, Walter Bright wrote:
 On 4/7/2014 6:48 AM, asman wrote:
 Could be great too if someone run a static analyzer like on dmd
 code http://www.cppcat.com I'll try when I back to Windows
The static analyzer PVS-Studio was run on dmd last year. It found 2 bugs, and several thousand false positives.
The results for Intel's compiler are just waiting for someone to approve the post, as it's 72kb in a 7z file. (posts larger than 40kb have to be manually approved according to the email that got sent back to me)
Apr 07 2014
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/7/2014 10:15 AM, Orvid King wrote:
 On Monday, 7 April 2014 at 17:05:46 UTC, Walter Bright wrote:
 On 4/7/2014 6:48 AM, asman wrote:
 Could be great too if someone run a static analyzer like on dmd
 code http://www.cppcat.com I'll try when I back to Windows
The static analyzer PVS-Studio was run on dmd last year. It found 2 bugs, and several thousand false positives.
The results for Intel's compiler are just waiting for someone to approve the post, as it's 72kb in a 7z file. (posts larger than 40kb have to be manually approved according to the email that got sent back to me)
Please just email it to me. I don't think it's useful to post such gigantic files. Also, being a text forum, posting zip files is not terribly useful, either.
Apr 07 2014
next sibling parent reply "asman" <lol.themask gmail.com> writes:
On Monday, 7 April 2014 at 17:49:01 UTC, Walter Bright wrote:
 On 4/7/2014 10:15 AM, Orvid King wrote:
 On Monday, 7 April 2014 at 17:05:46 UTC, Walter Bright wrote:
 On 4/7/2014 6:48 AM, asman wrote:
 Could be great too if someone run a static analyzer like on 
 dmd
 code http://www.cppcat.com I'll try when I back to Windows
The static analyzer PVS-Studio was run on dmd last year. It found 2 bugs, and several thousand false positives.
The results for Intel's compiler are just waiting for someone to approve the post, as it's 72kb in a 7z file. (posts larger than 40kb have to be manually approved according to the email that got sent back to me)
Please just email it to me. I don't think it's useful to post such gigantic files. Also, being a text forum, posting zip files is not terribly useful, either.
Could this forum has basic HTML support? code highlight or even some text formatting in text itself could be very useful, either.
Apr 07 2014
next sibling parent Walter Bright <newshound2 digitalmars.com> writes:
On 4/7/2014 12:02 PM, asman wrote:
 Could this forum has basic HTML support? code highlight or even some text
 formatting in text itself could be very useful, either.
Not worth the complexity, bandwidth, security issues, not all newsreaders support that, etc.
Apr 07 2014
prev sibling next sibling parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Mon, Apr 07, 2014 at 07:02:11PM +0000, asman wrote:
[...]
 Could this forum has basic HTML support? code highlight or even some
 text formatting in text itself could be very useful, either.
Please don't. I don't use a HTML mail reader, and I never will. All the information that is relevant to D coding is adequately conveyed by plain text. HTML only adds unnecessary frills that contributes no substance while adding bloat. T -- MAS = Mana Ada Sistem?
Apr 07 2014
prev sibling parent reply "Mike Parker" <aldacron gmail.com> writes:
On Monday, 7 April 2014 at 19:02:13 UTC, asman wrote:

 Could this forum has basic HTML support? code highlight or even 
 some text formatting in text itself could be very useful, 
 either.
Not everyone uses the web interface. Some people are using the mailing list interface, others using newsreaders, and not everyone is using a client that supports HTML.
Apr 07 2014
parent reply "Dicebot" <public dicebot.lv> writes:
On Tuesday, 8 April 2014 at 03:44:40 UTC, Mike Parker wrote:
 On Monday, 7 April 2014 at 19:02:13 UTC, asman wrote:

 Could this forum has basic HTML support? code highlight or 
 even some text formatting in text itself could be very useful, 
 either.
Not everyone uses the web interface. Some people are using the mailing list interface, others using newsreaders, and not everyone is using a client that supports HTML.
We can possibly support code highlighting same as vibe.d newsgroup web interface does: just render ``` code here ``` blocks as code snippets (example: http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/15414/) while still showing them as normal text in mails / NG clients. Feels natural to any GitHub user.
Apr 08 2014
parent "John Colvin" <john.loughran.colvin gmail.com> writes:
On Tuesday, 8 April 2014 at 12:40:16 UTC, Dicebot wrote:
 On Tuesday, 8 April 2014 at 03:44:40 UTC, Mike Parker wrote:
 On Monday, 7 April 2014 at 19:02:13 UTC, asman wrote:

 Could this forum has basic HTML support? code highlight or 
 even some text formatting in text itself could be very 
 useful, either.
Not everyone uses the web interface. Some people are using the mailing list interface, others using newsreaders, and not everyone is using a client that supports HTML.
We can possibly support code highlighting same as vibe.d newsgroup web interface does: just render ``` code here ``` blocks as code snippets (example: http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/15414/) while still showing them as normal text in mails / NG clients. Feels natural to any GitHub user.
This is the only bit of formatting I'd be interested in.
Apr 08 2014
prev sibling parent reply "Orvid King" <blah38621 gmail.com> writes:
On Mon, 07 Apr 2014 12:49:05 -0500, Walter Bright  
<newshound2 digitalmars.com> wrote:

 On 4/7/2014 10:15 AM, Orvid King wrote:
 On Monday, 7 April 2014 at 17:05:46 UTC, Walter Bright wrote:
 On 4/7/2014 6:48 AM, asman wrote:
 Could be great too if someone run a static analyzer like on dmd
 code http://www.cppcat.com I'll try when I back to Windows
The static analyzer PVS-Studio was run on dmd last year. It found 2 bugs, and several thousand false positives.
The results for Intel's compiler are just waiting for someone to approve the post, as it's 72kb in a 7z file. (posts larger than 40kb have to be manually approved according to the email that got sent back to me)
Please just email it to me. I don't think it's useful to post such gigantic files. Also, being a text forum, posting zip files is not terribly useful, either.
As suggested I've posted it as an attachment to an issue, https://issues.dlang.org/show_bug.cgi?id=12552
Apr 09 2014
parent Walter Bright <newshound2 digitalmars.com> writes:
On 4/9/2014 11:10 AM, Orvid King wrote:
 As suggested I've posted it as an attachment to an issue,
 https://issues.dlang.org/show_bug.cgi?id=12552
Thanks!
Apr 09 2014