Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 181894 - Optimization level on g++ affects warnings for unused parameters
Summary: Optimization level on g++ affects warnings for unused parameters
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: gcc
Version: 4.0
Hardware: i586
OS: Linux
Target Milestone: ---
: ---
Assignee: Jakub Jelinek
QA Contact:
Depends On:
Blocks: RHEL3U8CanFix
TreeView+ depends on / blocked
Reported: 2006-02-17 16:42 UTC by Fritz Boehm
Modified: 2007-11-30 22:07 UTC (History)
2 users (show)

Fixed In Version: RHBA-2006-0454
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2006-07-20 14:32:46 UTC
Target Upstream Version:

Attachments (Terms of Use)
simple C++ program that shows the gcc behavior (deleted)
2006-02-17 16:42 UTC, Fritz Boehm
no flags Details

System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2006:0454 normal SHIPPED_LIVE gcc bug fix update 2006-07-19 18:39:00 UTC

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 -Wall -W -Werror -O2
2. compare that to compiling it like this:
g++ -c -Wall -W -Werror -O0

Actual results:

With -O2 I get no messages.  With -O0 I get this:
cc1plus: warnings being treated as errors In member function `virtual int master::foo(int, int)': warning: unused parameter `int var1' 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.

Comment 10 Jan Iven 2006-08-03 07:41:25 UTC
It looks like this g++ version now complains about unused parameters in system
warning: unused
   parameter `int __ibom'
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)

Note You need to log in before you can comment on or make changes to this bug.