[Bug c++/83806] New: Spurious unused-but-set-parameter with nullptr

barry.revzin at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Jan 11 18:37:00 GMT 2018


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

            Bug ID: 83806
           Summary: Spurious unused-but-set-parameter with nullptr
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

This program:

template <class X, class Y>
bool equals(X x, Y y) {
    return (x == y); 
}

int main() {
    const char* p = nullptr;
    equals(p, nullptr);
}

When compiled as:

$ g++ -std=c++1z -Wunused-but-set-parameter bad.cxx 
bad.cxx: In instantiation of ‘bool equals(X, Y) [with X = const char*; Y =
std::nullptr_t]’:
bad.cxx:8:22:   required from here
bad.cxx:2:20: warning: parameter ‘y’ set but not used
[-Wunused-but-set-parameter]
 bool equals(X x, Y y) {
                    ^

But y is used, in a meaningful sense.


More information about the Gcc-bugs mailing list