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]
Other format: [Raw text]

[Bug c++/61465] New: Bogus parameter set but not used warning in constructor initialization list


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61465

            Bug ID: 61465
           Summary: Bogus parameter set but not used warning in
                    constructor initialization list
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fanael4 at gmail dot com

When compiling the following code with C++11 and -Wunused-but-set-parameter on

struct Foo {
  Foo(void* x) : y{static_cast<char*>(x)} {}
  char* y;
};

GCC (tested on 4.7.0 and 4.9.1) incorrectly complains:

x.cpp:2:13: warning: parameter 'x' set but not used
[-Wunused-but-set-parameter]

Which is clear nonsense, as the parameter is used. If the initialization list
is changed to use parentheses, or the static_cast is removed and y's type is
changed, the warning goes away.


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