[Lldb-commits] [PATCH] EmulationStateARM: Don't have >= comparisons against dwarf_r0

Todd Fiala tfiala at google.com
Wed Jul 30 13:49:31 PDT 2014


Or you can disable warnings for that type, right?  "Don't warn about
comparsions to 0 for type {enum type}, because the whole reason I'm using
enums is so I don't have to worry about the value of the enum."

Don't let the compiler dictate writing less safe code.

That's like that lame switch coverage warning that tells you "you have a
(supposedly superfluous) default when all enum values are covered by the
switch".  And if the compiler can guarantee that something else in the
program doesn't inadvertently permute the switch variable to a value
outside the values of the enum, then great.  If not, that's a dangerous
warning.  I can't tell you the number of times I was glad I had a default
with some kind of sanity check on a game server to tip off a gnarly memory
overwrite condition.  Yet the easy thing to do here would be to remove the
default, and miss catching the case of a bogus value.

/rant off.

In this case, a comment is likely sufficient.  Another way to work around
this is to use a range-check method where the lower and upper bounds are
passed in, which would likely preserve both the intent and eliminate the
warning in one foul swoop :-)



On Wed, Jul 30, 2014 at 1:43 PM, Zachary Turner <zturner at google.com> wrote:

> Could probably address that concern with a comment, but the alternatives
> (disabling the warning or doing a cast to a signed type) both seem strictly
> worse than removing the code, and I'm a strong proponent of warning-free
> code across all platforms.
>
> http://reviews.llvm.org/D4629
>
>
>


-- 
Todd Fiala | Software Engineer | tfiala at google.com | 650-943-3180
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20140730/a7f12cca/attachment.html>


More information about the lldb-commits mailing list