This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Is a warning for a==a possible?
- From: Joe Buck <jbuck at synopsys dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 4 Dec 2003 09:40:02 -0800
- Subject: Re: Is a warning for a==a possible?
- References: <20031204135133.GA3387@inxservices.com>
On Thu, Dec 04, 2003 at 05:51:33AM -0800, George Garvey wrote:
> Just made a stupid mistake, and wondered if GCC could have warned about it?
>
> struct S {
> int A;
>
> bool f(const int a) {
> const bool r(A == A);
> a = 3;
> };
> };
>
> The first line in f() should have been r = A == a. No doubt there is a
> valid reason to compare something to itself that I can't see right now.
You're forgetting macros and machine-generated code, which might produce
something like A == A.