* Is a warning for a==a possible?
@ 2003-12-04 13:53 George Garvey
2003-12-04 17:43 ` Joe Buck
0 siblings, 1 reply; 2+ messages in thread
From: George Garvey @ 2003-12-04 13:53 UTC (permalink / raw)
To: gcc
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. Is
it possible for GCC to notice this?
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Is a warning for a==a possible?
2003-12-04 13:53 Is a warning for a==a possible? George Garvey
@ 2003-12-04 17:43 ` Joe Buck
0 siblings, 0 replies; 2+ messages in thread
From: Joe Buck @ 2003-12-04 17:43 UTC (permalink / raw)
To: gcc
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-12-04 17:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-04 13:53 Is a warning for a==a possible? George Garvey
2003-12-04 17:43 ` Joe Buck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).