Re: [Consult] g++: About "-Wunused-variable" for constant variable in header file

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

 



On 14 October 2014 22:57, Chen Gang <gang.chen.5i5j@xxxxxxxxx> 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.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux