Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > gnu.g++.bug > #4

possible -Wunused-variable bug

X-Received by 2002:a05:620a:1510:b0:6a3:9b95:196 with SMTP id i16-20020a05620a151000b006a39b950196mr10905763qkk.152.1654358229466; Sat, 04 Jun 2022 08:57:09 -0700 (PDT)
X-Received by 2002:a05:622a:1452:b0:304:5453:fa43 with SMTP id v18-20020a05622a145200b003045453fa43mr12397060qtx.297.1654358229289; Sat, 04 Jun 2022 08:57:09 -0700 (PDT)
Path csiph.com!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups gnu.g++.bug
Date Sat, 4 Jun 2022 08:57:09 -0700 (PDT)
Injection-Info google-groups.googlegroups.com; posting-host=94.52.87.195; posting-account=nD0UhgoAAAD7Ef2cuJsKLgVGgfFMGfsA
NNTP-Posting-Host 94.52.87.195
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <d5c837e2-c82a-4da0-94dc-3a5ea3b7ac5en@googlegroups.com> (permalink)
Subject possible -Wunused-variable bug
From Tibor Áser Veres <v.tibor.a@gmail.com>
Injection-Date Sat, 04 Jun 2022 15:57:09 +0000
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding quoted-printable
X-Received-Bytes 4348
Xref csiph.com gnu.g++.bug:4

Show key headers only | View raw


Hi!

I'm new here, and in the process of learning c++. Not sure where should I report bugs... for g++ compiler.

When I enabled -Wunused I'm getting these warnings:

In file included from /media/LocalDrives/SSD/Programs/HydraFort/Source/../HexaLib-GUI/HexaLib-GUI.h:23,
                 from /media/LocalDrives/SSD/Programs/HydraFort/Source/Main.cpp:2:
/media/LocalDrives/SSD/Programs/HydraFort/Source/../HexaLib-GUI/HLGlobals.h:17:33: warning: ‘HexaLib::AMask’ defined but not used [-Wunused-variable]
   17 |                 static uint32_t AMask = 0xff000000;
      |                                 ^~~~~
/media/LocalDrives/SSD/Programs/HydraFort/Source/../HexaLib-GUI/HLGlobals.h:16:33: warning: ‘HexaLib::BMask’ defined but not used [-Wunused-variable]
   16 |                 static uint32_t BMask = 0x00ff0000;
      |                                 ^~~~~
/media/LocalDrives/SSD/Programs/HydraFort/Source/../HexaLib-GUI/HLGlobals.h:15:33: warning: ‘HexaLib::GMask’ defined but not used [-Wunused-variable]
   15 |                 static uint32_t GMask = 0x0000ff00;
      |                                 ^~~~~
/media/LocalDrives/SSD/Programs/HydraFort/Source/../HexaLib-GUI/HLGlobals.h:14:33: warning: ‘HexaLib::RMask’ defined but not used [-Wunused-variable]
   14 |                 static uint32_t RMask = 0x000000ff;
      |                                 ^~~~~
In file included from /media/LocalDrives/SSD/Programs/HydraFort/HexaLib/HexaLib.h:23,
                 from /media/LocalDrives/SSD/Programs/HydraFort/Source/../HexaLib-GUI/HexaLib-GUI.h:22,
                 from /media/LocalDrives/SSD/Programs/HydraFort/Source/Main.cpp:2:
/media/LocalDrives/SSD/Programs/HydraFort/HexaLib/HexaLog.h:28:21: warning: ‘HexaLib::AppendFile’ defined but not used [-Wunused-variable]
   28 |         static bool AppendFile = false;
      |                     ^~~~~~~~~~
/media/LocalDrives/SSD/Programs/HydraFort/HexaLib/HexaLog.h:26:25: warning: ‘HexaLib::TraceFocus’ defined but not used [-Wunused-variable]
   26 |         static uint16_t TraceFocus = 0; // 0 = Silent, Trace>0 = focus that trace, 65535 = Default trace(if no Trace specified...)
      |                         ^~~~~~~~~~
/media/LocalDrives/SSD/Programs/HydraFort/HexaLib/HexaLog.h:25:21: warning: ‘HexaLib::LogLevel’ defined but not used [-Wunused-variable]
   25 |         static char LogLevel = 'I'; // 'S' = Silent, 'E' = Errors, 'W' Errors and  Warnings, 'I' = Errors, Warnings, and Info 'D' everything including debug messages.
      |                     ^~~~~~~~

I checked all of those variables are used, and my program works just fine. In fact if I remove any of them I get errors instead...

The common thing about them is that they are all static global variables, within the HexaLib namespace.

Here's the g++ version:
g++ (Ubuntu 11.2.0-19ubuntu1) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Back to gnu.g++.bug | Previous | Find similar


Thread

possible -Wunused-variable bug Tibor Áser Veres <v.tibor.a@gmail.com> - 2022-06-04 08:57 -0700

csiph-web