[Issue 10480] Warning against wrong usage of incorrect operator for bits set test

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jun 26 17:20:13 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10480



--- Comment #2 from bearophile_hugs at eml.cc 2013-06-26 17:20:12 PDT ---
(In reply to comment #1)
> I'm unhappy with making this an error or a warning. It's perfectly reasonable
> to write code that tests something that is (at compile time) always true or
> false. This can happen:
> 
> 1. in generic code
> 
> 2. in reasonable attempts to avoid versioning
> 
> 3. D code idiomatically does quite a bit more at compile time than other
> languages do. This change would make that more difficult.
> 
> 4. in temporary debugging code, like:
> 
>     if (0 && condition) ...

Thank you for your answer. I have opened this issue because:
- I think a bit of static analysis from the compiler goes a long way avoiding
common simple programmer mistakes.
- I think being aware of a problem is important even when I don't know how to
solve it, so having this enhancement request in Bugzilla is important to
remember it.
- In both the article that has spurred this ER and in the warning in the Visual
Studio, some intelligent persons think it's a common bug and a good to have
warning for C++.

I have now gained some experience on how D is designed and how you want it to
be designed (nearly no warnings, avoid false positives as much as possible,
help generic code and compile time coding), so I understand such problems. If
you want I will close down this issue.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list