http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59624

            Bug ID: 59624
           Summary: bizarre warning about 'assigned but unused parameter'
                    in ctor
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mw_triad at users dot sourceforge.net

Created attachment 31538
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31538&action=edit
SSCCE showing the bug

Consider the following code:

// foo is a class, rc is an enum class
foo::foo(rc c) : v{static_cast<int>(c)} {}

g++ with -std=c++11 -Wall -Wextra warns:
foo.cpp:8:3: warning: parameter ā€˜cā€™ set but not used
[-Wunused-but-set-parameter]

...but there is no assignment occurring?!

I suspect under the covers this is due to C++ DR1288 (i.e. see bug #50025 of
which this is possibly either a duplicate or just goes away if that is fixed,
but will let someone else make that call), but for otherwise-warning-free code
it's quite obnoxious, as there does not appear to be anything wrong with the
code.

Goes away if ()'s are used instead of {}'s for the initialization.

(Full SSCCE is attached.)

Reply via email to