I think this is a recent regression:
-----------------------------
int memory_consumption(const int &t) { return sizeof(t); }

int s;
int g() { return memory_consumption(s); }
-----------------------------

deal.II> c++ -c -W -Wunused ../x.cc
../x.cc:1:5: warning: unused parameter 't'

Quite formally, it is probably correct to say that the parameter is unused
because we don't read or write from/to it. But I think it's still a kind of
use to determine its size and the warning should be suppressed in my
opinion.

In the meantime, the warning can of course be trivially suppressed by
saying
  sizeof(int)
instead.

W.


-- 
           Summary: [4.5 regression] Argument flagged as unused despite use
                    in sizeof()
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bangerth at gmail dot com


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

Reply via email to