[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Warnings/errors related to possibly clobbered variables

From: Eli Zaretskii
Subject: Re: Warnings/errors related to possibly clobbered variables
Date: Tue, 13 Jan 2015 22:10:05 +0200

> From: Stefan Monnier <address@hidden>
> Cc: Dmitry Antipov <address@hidden>,  address@hidden,  address@hidden,  
> address@hidden
> Date: Tue, 13 Jan 2015 14:43:11 -0500
> > Why not declare the offending variables 'volatile' and forget about
> > all this stuff?
> FWIW, `volatile' might not necessarily give us the behavior we
> want/need.

How so?  Are you saying that qualifying an automatic variable as
'volatile' might change the semantics of the program?

> IOW if the warning is legit, we should investigate and
> decide exactly how to fix the problem (which might involve using
> `volatile' or it might on the contrary involve making a copy of the
> current value).
> If the warning is not legit, then it's a problem in GCC and we shouldn't
> do anything on our side other than report a bug.

The compiler is rarely wrong in these cases, especially if the warning
comes from several different versions of it.  Programs are much better
than people in examining control flow.  They don't understand the
hidden relations between the offending variable and other conditions,
so they can flag problems that don't really exist.  But they rarely
flag something that is clearly wrong.

IME, adding 'volatile' is generally TRT in these cases.  Plus, it's
very simple, and goes "by the book" (a.k.a. the C Standard).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]