[Issue 6949] no warning or error if unsigned variable is compared to 0

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 30 06:31:18 PST 2012


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



--- Comment #15 from Don <clugdbug at yahoo.com.au> 2012-11-30 06:31:17 PST ---
(In reply to comment #14)
> (In reply to comment #13)
> > (In reply to comment #12)
> > > Regarding a comment by Don, is it possible to generate a warning/error only in
> > > foo() and not in bar()?
> > > 
> > > 
> > > void foo(uint x) {
> > >     if (x < 0) {} // error or warning here
> > > }
> > > void bar(T)(T x) {
> > >     if (x < 0) {} // OK
> > > }
> > > void main() {
> > >     foo(5U);
> > >     bar(5U);
> > > }
> > 
> > I doubt it.
> 
> I'd like a better answer about this, maybe from Don or Hara or someone that
> knows this answer better.

It's easy.
DSymbol.inTemplateInstance()  returns non-NULL if you are inside a template.
You just need to call it on the function you're in.

BTW std.bigint has a lot of examples of valid comparisons of  unsigned < 0 .

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