No warning for module global variable which is set but never used
Jonathan Wakely
jwakely.gcc@gmail.com
Wed Dec 9 09:39:03 GMT 2020
On Wed, 9 Dec 2020 at 09:28, webmaster <webmaster@defcon-cc.org> wrote:
>
> Hello,I'm wondering why GCC does not throw any warning when a module global variable is set (write) but never used (read).Is this behavior wanted? Does it makes sense to add such warning?Greets
This question seems to be more appropriate for the gcc-help list.
Please take any replies to that list instead.
What do you mean by "module"? A Fortran module? A C++ module? Or do
you just mean a source file?
In C and C++ global variables have external linkage by default, which
means they can be accessed from another translation unit (i.e. another
source file). Unless the compiler knows that the entire program is a
single source file, it can't know that there aren't writes to the
variable in other files.
More information about the Gcc
mailing list