Bug 181894

Summary: Optimization level on g++ affects warnings for unused parameters
Product: Red Hat Enterprise Linux 4 Reporter: Fritz Boehm <fritz>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact:
Severity: low Docs Contact:
Priority: medium    
Version: 4.0CC: aoliva, jan.iven
Target Milestone: ---   
Target Release: ---   
Hardware: i586   
OS: Linux   
Whiteboard:
Fixed In Version: RHBA-2006-0454 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-07-20 14:32:46 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 181405    
Attachments:
Description Flags
simple C++ program that shows the gcc behavior none

Description Fritz Boehm 2006-02-17 16:42:20 UTC
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)


How reproducible:
Every time.


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

  
Actual results:

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'



Expected results:
I would expect the warnings regardless of optimization level.

Additional info:

Comment 1 Fritz Boehm 2006-02-17 16:42:20 UTC
Created attachment 124822 [details]
simple C++ program that shows the gcc behavior

Comment 4 Bob Johnson 2006-04-11 15:48:30 UTC
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.

Comment 9 Red Hat Bugzilla 2006-07-20 14:32:46 UTC
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.

http://rhn.redhat.com/errata/RHBA-2006-0454.html


Comment 10 Jan Iven 2006-08-03 07:41:25 UTC
It looks like this g++ version now complains about unused parameters in system
files:
/usr/include/c++/3.2.3/i386-redhat-linux/bits/codecvt_specializations.h:84:
warning: unused
   parameter `int __ibom'
/usr/include/c++/3.2.3/i386-redhat-linux/bits/codecvt_specializations.h:84:
warning: unused
   parameter `int __ebom'
/usr/include/c++/3.2.3/bits/locale_facets.h:1014: warning: unused parameter `
   size_t __refs'
...
(this is also reported as Issue#99250)