public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Chen Gang <gang.chen.5i5j@gmail.com>
To: Jonathan Wakely <jwakely.gcc@gmail.com>
Cc: gcc-help <gcc-help@gcc.gnu.org>, Jeff Law <law@redhat.com>,
	 Peter Maydell <peter.maydell@linaro.org>,
	Jakub Jelinek <jakub@redhat.com>
Subject: Re: [Consult] g++: About "-Wunused-variable" for constant variable in header file
Date: Wed, 15 Oct 2014 09:29:00 -0000	[thread overview]
Message-ID: <543E3FE4.9070102@gmail.com> (raw)
In-Reply-To: <CAH6eHdShDVT4Of6NJuqQfWY=Xcr6uUQVeyui87X+udMCdcurvQ@mail.gmail.com>

On 10/15/14 17:18, Jonathan Wakely wrote:
> On 14 October 2014 22:57, Chen Gang <gang.chen.5i5j@gmail.com> wrote:
>> Hello All:
>>
>> At present, I met one warning issue about gcc 5.0.0.
>>
>>  - For "const float a = 3.4 - 2.1 / 3;", if it is unused, gcc5 will not
>>    report warning.
> 
> Because there is no cost to initializing the variable.
> 
>>  - "const char n() {return 1;}; const a = n();", if 'a' is unused, gcc5
>>    will report warning.
> 
> Because it requires dynamic initialization, running a function at
> startup, which has a cost. If you don't use the variable then you
> might not want to run the initialization code at startup, so you get a
> warning.
> 
>> For gcc old version (e.g. gcc4), it will not report warning. Is it the
>> new feature for gcc5, or just a gcc5's bug?
> 
> I think this behaviour is intended and is not a bug.
> 

Thank you very much four your details reply! And thank Jakub Jelinek for
the almost same reply in another original mailing thread, too.

I shall forward your reply to the other related mail thread which is
related with QEMU.

Thanks again.  :-)

-- 
Chen Gang

Open, share, and attitude like air, water, and life which God blessed

      reply	other threads:[~2014-10-15  9:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-14 21:57 Chen Gang
2014-10-15  9:18 ` Jonathan Wakely
2014-10-15  9:29   ` Chen Gang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=543E3FE4.9070102@gmail.com \
    --to=gang.chen.5i5j@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jwakely.gcc@gmail.com \
    --cc=law@redhat.com \
    --cc=peter.maydell@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).