[Issue 8757] Require parenthesization of ternary operator when compounded

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jun 26 18:03:27 PDT 2013


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



--- Comment #10 from Jonathan M Davis <jmdavisProg at gmx.com> 2013-06-26 18:03:25 PDT ---
> What evidence do you have to back your claim?

My experience with the incredibly stupid stuff that Visual Studio likes to
complain about. My favorite example would be converting to bool. C++ allows
implicit conversion to bool for built-in types, so it's perfectly legal to do
stuff like

bool foo(int* bar)
{
    return bar;
}

But the VS insists on complaining about a lot of conversions to bool -
particularly when returning. It doesn't even like casts (complaining about
potentially inefficient code, which makes no sense, since it would be trivial
to adjust the code to be more efficient without changing the semantics). If you
don't turn that warning off, you're forced to do stuff like

return bar != 0;

or

return bar ? true : false;

It would be one thing if the language had more restrictive conversion rules
(like D), but it doesn't. So, VS ends up complaining about stuff which is
perfectly valid C++ and not buggy in the least. It's _really_, _really_
annoying, and that's just _one _example.

The compiler shouldn't be complaining about stuff that isn't actually broken.
And it _definitely_ shouldn't be complaining about stuff that is 100% valid in
the language and is 100% correct code just because some compiler writer decided
that they thought that people should or shouldn't write their code in a
particular way.

-- 
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