Red Hat Bugzilla – Bug 181894
Optimization level on g++ affects warnings for unused parameters
Last modified: 2007-11-30 17:07:23 EST
Description of problem:
When -O2 is used to compile the file (below) no warnings are produced. When -O0
is used, however, warnings are (correctly) given.
Version-Release number of selected component (if applicable):
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-49)
Steps to Reproduce:
1. compile attached program like this:
g++ -c test.cc -Wall -W -Werror -O2
2. compare that to compiling it like this:
g++ -c test.cc -Wall -W -Werror -O0
With -O2 I get no messages. With -O0 I get this:
cc1plus: warnings being treated as errors
test.cc: In member function `virtual int master::foo(int, int)':
test.cc:3: warning: unused parameter `int var1'
test.cc:3: warning: unused parameter `int var2'
I would expect the warnings regardless of optimization level.
Created attachment 124822 [details]
simple C++ program that shows the gcc behavior
This issue is on Red Hat Engineering's list of planned work items
for the upcoming Red Hat Enterprise Linux 3.8 release. Engineering
resources have been assigned and barring unforeseen circumstances, Red
Hat intends to include this item in the 3.8 release.
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.
It looks like this g++ version now complains about unused parameters in system
parameter `int __ibom'
parameter `int __ebom'
/usr/include/c++/3.2.3/bits/locale_facets.h:1014: warning: unused parameter `
(this is also reported as Issue#99250)