This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/2356: Wrong "unused parameter" warnings with -W -Wall



>Number:         2356
>Category:       c++
>Synopsis:       Wrong "unused parameter" warnings with -W -Wall
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 23 01:56:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Matti Rintala
>Release:        3.0 20010320 (prerelease)
>Organization:
Tampere University of Technology
>Environment:
System: Linux mustikkakukko.cs.tut.fi 2.4.0-0.99.23 #1 Tue Feb 6 02:34:20 EST 2001 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --prefix=/usr/local/gcc-3-test --enable-shared --enable-threads --with-cpu=i686 --enable-cpp --enable-languages=c++ : (reconfigured) 
>Description:
	g++ incorrectly warns about unused parameters even when the parameter
	names are omitted from the function definition, if the parameter names
	are used in the function declaration. This happens at least with
	constructors, including compiler-generated copy constructors in the
	library's exception classes.
>How-To-Repeat:
	Here's a small sample file:
--------test.cc-----------
#include <new>

class X
{
public:
  X(int i);
};

X::X(int)
{
  throw std::bad_alloc();
}
-------- after g++ -v --save-temps -Wall -W -c test.cc >& test.gccout -----
---------test.gccout------------
Reading specs from /usr/local/gcc-3-test/lib/gcc-lib/i686-pc-linux-gnu/3.0/specs
Configured with: ../gcc/configure --prefix=/usr/local/gcc-3-test --enable-shared --enable-threads --with-cpu=i686 --enable-cpp --enable-languages=c++ : (reconfigured) 
gcc version 3.0 20010320 (prerelease)
 /usr/local/gcc-3-test/lib/gcc-lib/i686-pc-linux-gnu/3.0/cpp0 -lang-c++ -D_GNU_SOURCE -D__GNUG__=3 -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__STDC_HOSTED__=1 -Wall -W -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ test.cc test.ii
GNU CPP version 3.0 20010320 (prerelease) (cpplib) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/gcc-3-test/include/g++-v3
 /usr/local/gcc-3-test/include/g++-v3/i686-pc-linux-gnu
 /usr/local/include
 /usr/local/gcc-3-test/lib/gcc-lib/i686-pc-linux-gnu/3.0/include
 /usr/local/gcc-3-test/i686-pc-linux-gnu/include
 /usr/include
End of search list.
 /usr/local/gcc-3-test/lib/gcc-lib/i686-pc-linux-gnu/3.0/cc1plus -fpreprocessed test.ii -quiet -dumpbase test.cc -Wall -W -version -o test.s
GNU CPP version 3.0 20010320 (prerelease) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.0 20010320 (prerelease) (i686-pc-linux-gnu)
	compiled by GNU C version 3.0 20010320 (prerelease).
test.cc: In method `X::X(int)':
test.cc:6: warning: unused parameter `int i'
test.cc: In method `X::X(int)':
test.cc:6: warning: unused parameter `int i'
test.cc: In method `std::exception::exception(const std::exception&)':
/usr/local/gcc-3-test/include/g++-v3/exception:41: warning: unused parameter `
   const std::exception&_ctor_arg'
 as -V -Qy -o test.o test.s
GNU assembler version 2.10.90 (i386-redhat-linux) using BFD version 2.10.0.18

---------test.ii------------
# 1 "test.cc"
# 1 "/usr/local/gcc-3-test/include/g++-v3/new" 1 3
# 34 "/usr/local/gcc-3-test/include/g++-v3/new" 3
#pragma interface "new"
# 1 "/usr/local/gcc-3-test/include/g++-v3/cstddef" 1 3

# 1 "/usr/local/gcc-3-test/include/g++-v3/bits/std_cstddef.h" 1 3
# 40 "/usr/local/gcc-3-test/include/g++-v3/bits/std_cstddef.h" 3
# 1 "/usr/local/gcc-3-test/lib/gcc-lib/i686-pc-linux-gnu/3.0/include/stddef.h" 1 3
# 147 "/usr/local/gcc-3-test/lib/gcc-lib/i686-pc-linux-gnu/3.0/include/stddef.h" 3
typedef int ptrdiff_t;
# 199 "/usr/local/gcc-3-test/lib/gcc-lib/i686-pc-linux-gnu/3.0/include/stddef.h" 3
typedef unsigned int size_t;
# 41 "/usr/local/gcc-3-test/include/g++-v3/bits/std_cstddef.h" 2 3

namespace std
{
  using ::ptrdiff_t;
  using ::size_t;
}
# 3 "/usr/local/gcc-3-test/include/g++-v3/cstddef" 2 3
# 36 "/usr/local/gcc-3-test/include/g++-v3/new" 2 3
# 1 "/usr/local/gcc-3-test/include/g++-v3/exception" 1 3
# 34 "/usr/local/gcc-3-test/include/g++-v3/exception" 3
#pragma interface "exception"

extern "C++" {

namespace std
{
  class exception
  {
  public:
    exception() throw() { }
    virtual ~exception() throw() { }
    virtual const char* what() const throw();
  };

  class bad_exception : public exception
  {
  public:
    bad_exception() throw() { }
    virtual ~bad_exception() throw() { }
  };

  typedef void (*terminate_handler) ();
  typedef void (*unexpected_handler) ();

  terminate_handler set_terminate(terminate_handler) throw();
  void terminate() __attribute__ ((__noreturn__));

  unexpected_handler set_unexpected(unexpected_handler) throw();
  void unexpected() __attribute__ ((__noreturn__));

  bool uncaught_exception() throw();
}

}
# 37 "/usr/local/gcc-3-test/include/g++-v3/new" 2 3

extern "C++" {

namespace std
{
  class bad_alloc : public exception
  {
  public:
    virtual const char* what() const throw() { return "bad_alloc"; }
  };

  struct nothrow_t { };
  extern const nothrow_t nothrow;
  typedef void (*new_handler)();
  new_handler set_new_handler(new_handler);
}


void *operator new(std::size_t) throw (std::bad_alloc);
void *operator new[](std::size_t) throw (std::bad_alloc);
void operator delete(void *) throw();
void operator delete[](void *) throw();
void *operator new(std::size_t, const std::nothrow_t&) throw();
void *operator new[](std::size_t, const std::nothrow_t&) throw();
void operator delete(void *, const std::nothrow_t&) throw();
void operator delete[](void *, const std::nothrow_t&) throw();


inline void *operator new(std::size_t, void *place) throw() { return place; }
inline void *operator new[](std::size_t, void *place) throw() { return place; }
}
# 2 "test.cc" 2

class X
{
public:
  X(int i);
};

X::X(int)
{
  throw std::bad_alloc();
}

>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]