This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [Consult] g++: About "-Wunused-variable" for constant variable initialized by function
- From: Chen Gang <gang dot chen dot 5i5j at gmail dot com>
- To: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- Cc: Jason Merrill <jason at redhat dot com>, Jeff Law <law at redhat dot com>, Nathan Sidwell <nathan at codesourcery dot com>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>, Peter Maydell <peter dot maydell at linaro dot org>
- Date: Wed, 22 Oct 2014 22:32:33 +0800
- Subject: Re: [Consult] g++: About "-Wunused-variable" for constant variable initialized by function
- Authentication-results: sourceware.org; auth=none
- References: <543A910F dot 7060301 at gmail dot com> <543BAF23 dot 6080808 at redhat dot com> <543BD122 dot 5010201 at gmail dot com> <543E4769 dot 30006 at gmail dot com> <54470C5B dot 3030205 at gmail dot com> <CAH6eHdQDV1QvpimycQXG6TFprw0HKSGWBfKzEx48V0Uj8AGiFw at mail dot gmail dot com>
On 10/22/2014 09:44 PM, Jonathan Wakely wrote:
> On 22 October 2014 02:46, Chen Gang <gang.chen.5i5j@gmail.com> wrote:
>> On 10/15/14 18:07, Chen Gang wrote:
>>> On 10/13/14 21:18, Chen Gang wrote:
>>>> On 10/13/14 18:53, Jason Merrill wrote:
>>>>> On 10/12/2014 10:32 AM, Chen Gang wrote:
>>>>>> [root@localhost qemu_cc]# cat test.cc
>>>>>> const char n() { return 1; }
>>>>>> const char c = n();
>>>>>> [root@localhost qemu_cc]# /usr/local/bin/g++ -Wall -O0 -c -o test.o test.cc
>>>>>> [root@localhost qemu_cc]# /usr/local/bin/g++ -Wall -O2 -c -o test.o test.cc
>>>>>> test.cc:2:12: warning: 'c' defined but not used [-Wunused-variable]
>>>>>> const char c = n();
>>>>>> ^
>>>>>
>>>>> The warning is correct (and new). Please submit bug reports via the website; see https://gcc.gnu.org/bugs/
>>>>>
>>
>> Aftr trying, I can not make a new account for gcc bugzilla.
>>
>> - Before file a bug, it is mandatory to have an acount.
>>
>> - I try to register a new account on the website, it said that need
>> send mail to overseers@gcc.gnu.org.
>>
>> - I sent related mail to overseers@gcc.gnu.org, but get no response.
>>
>> Need I wait for some days? or could any member help to file this bug to
>> gcc bugzilla?
>>
>> And whether it is OK or not, I shall try to analyze this issue directly,
>> I should try to finish it within 2014-10-31 (although I am really not
>> quite sure about it).
>
> I thought we'd established this is not a bug.
>
OK, thanks. I guess your meaning is that this warning is only for
optimization (let user notice to speed up performance and save code size
), not for correctness, so:
- it is reasonable to report warning when user requires optimization
(-O1|2|3|s).
- and also, need not report warning when user do not need optimization
(-O0).
If what I guess is correct, at least for me, it sounds reasonable, and
welcome any other members' ideas, suggestions or completions.
Thanks
--
Chen Gang
Open share and attitude like air water and life which God blessed