This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: comparisons..


> unsigned long x;
>  
> int y()
> {
>         return (x < 0);
> }
> 
> This is usually a bug.  Is there a way of getting gcc to warn about it?

GCC knows exactly that the expression is zero; with -O2
-fomit-frame-pointer, it generates

y:
	xorl %eax,%eax
	ret

However, what exactly is the "usual" bug here? That an expression can
be computed statically? 

Regards,
Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]