This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: New gcc 4.0.0 warnings seem spurious
Vincent Lefevre writes:
> On 2005-04-27 11:37:51 +0100, Andrew Haley wrote:
> > Warnings are to help the programmer see where there is some code that,
> > although not necessarily an error, may require some attention. This
> > is a classic case of such a warning. This warning really does
> > indicate to the programmer that there might be a real problem.
>
> On the other hand, too many warnings may annoy the programmer and have
> the opposite effect.
Yes, but this isn't an example of a spurious warning. It's a really
good warning, one that ought to be given.
> > > and IMHO, there should be a way to disable it (possibly locally to
> > > some part of the program).
> >
> > Why not just fix the code?
>
> I don't like the word "fix" since it is correct.
But that applies to most warnings.
if (a = b)
is correct too.
> > > But if they are never modified, they evaluate to constants, right?
> > >
> > > The fact that they are not considered as constant expressions,
> > > is it due to the fact that the environment is allowed to modify
> > > them?
> >
> > It's due to what the C standard says. A const variable in C isn't a
> > constant, it's just a read-only variable.
>
> 1+1 isn't a constant either, but is allowed anyway.
You said "if they are never modified, they evaluate to constants,
right?" To which the correct answer is "no, they don't".
Andrew.