This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C] Fix PR57258: unused variable warning is emitted for volatile variables
- From: "Bin.Cheng" <amker dot cheng at gmail dot com>
- To: Mike Stump <mikestump at comcast dot net>
- Cc: Mingjie Xing <mingjie dot xing at gmail dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>, Richard Biener <richard dot guenther at gmail dot com>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 8 Nov 2013 17:32:39 +0800
- Subject: Re: [C] Fix PR57258: unused variable warning is emitted for volatile variables
- Authentication-results: sourceware.org; auth=none
- References: <CADNgcEwhF9u2S=f3GdLtWo98BBQs-BVdzRh7-mspQHBAHhUYaw at mail dot gmail dot com> <CAFiYyc1OtvdCoawpsSStPF=qZJN+DHJUy_Hn=6a=9Tmk0uPp6g at mail dot gmail dot com> <CADNgcEzv0gdtADDwE1V4yn1ruwVE32eOocXk_HmLtcPhDiWu3w at mail dot gmail dot com> <Pine dot LNX dot 4 dot 64 dot 1311071335560 dot 17103 at digraph dot polyomino dot org dot uk> <CADNgcEw_xtipAL-iEyNZj5UO5=+RwjoE584aLRGp3oouqF_xAw at mail dot gmail dot com> <BC5C730B-0DBF-4E42-9ADD-995372336C40 at comcast dot net>
On Fri, Nov 8, 2013 at 5:03 PM, Mike Stump <mikestump@comcast.net> wrote:
> On Nov 7, 2013, at 5:13 PM, Mingjie Xing <mingjie.xing@gmail.com> wrote:
>> Well, it is my understanding that the warning should be emitted for a
>> volatile variable only if it is not accessed. Initialization means
>> accessing, even though it is not used anywhere.
>
> Let me try. A warning is useful, if there is no way a conforming program can tell that the variable exists or not. So, the question is, how can you notice the variable? Answer, there is no way, so, there is no utility in having the variable. The warning is to tell the user to remove the dead variable.
I am sort of lost. The bug is straightforward and it suggests the
volatile variable is actually used if it is declared with an
initialization, and GCC should not emit warning message for it.
The patch is fixing this, right? Any explanation?
Thanks,
bin
--
Best Regards.