Static Analysis Tooling / Effective D

Marco Leise via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 23 20:15:01 PDT 2014


Am Wed, 23 Apr 2014 22:56:27 -0400
schrieb "Steven Schveighoffer" <schveiguy at yahoo.com>:

> On Wed, 23 Apr 2014 22:56:54 -0400, Marco Leise <Marco.Leise at gmx.de> wrote:
> 
> > Am Tue, 21 Jan 2014 04:34:56 +0000
> > schrieb "Brian Schott" <briancschott at gmail.com>:
> >
> >> There's a small feature wishlist in the project's README, but I'd
> >> like to get some opinions from the newsgroup: What kinds of
> >> errors have you seen in your code that you think a static
> >> analysis tool could help with?
> >
> > Yes, this one:
> >
> > size_t shiftAmount = 63;
> > […]
> > auto x = 1 << shiftAmount;
> >
> > The trouble is that auto will now resolve to int instead of
> > size_t as indicated by the type of shiftAmount. Sure, my fault
> > was to use an innocent »1« instead of »cast(size_t) 1«.
> 
> You could use 1UL instead.
> 
> -Steve

No, that would give you a ulong result.

-- 
Marco



More information about the Digitalmars-d mailing list