buggperf - Bugs: bug #64393, -Wunused-parameter

 
 

bug #64393: -Wunused-parameter

Submitter:  Vinícius dos Santos Oliveira <vinipsmaker>
Submitted:  Sat 08 Jul 2023 02:35:31 AM UTC
   
 
Category:  Generated code Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  haible
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 08 Jul 2023 10:32:21 AM UTC, comment #1: 
Bruno Haible <haible>
Group administrator
Sat 08 Jul 2023 02:35:31 AM UTC, original submission:  

I use gperf extensively across my codebase (e.g. 20 gperf invocations per translation unit). For some of the functions, code such as the following is generated:


gperf__src_unix_cpp_20::hash (const char *str, size_t len)
{
  return len;
}


When every input string differs in size, the size itself becomes the hash function. So far so good, but the the argument `str` is unused and lots of warnings per file are generated which pollutes my build output considerably:


libemilua.a.p/bc2_unix.cpp:3937:43: warning: unused parameter 'str' [-Wunused-parameter]
gperf__src_unix_cpp_20::hash (const char *str, size_t len)
                                          ^
16 warnings generated.


All warnings from this single translation unit come from gperf (I stitch multiple gperf invocations to a single translation unit using an AWK script, but that's not important).

I don't know why, but sometimes `len` is the unused argument. Sample output:


gperf__src_unix_cpp_17::hash (const char *str, size_t len)
{
  return 0;
}


What I'd like to see is a standard header that is always included in the body of the implementation for these functions:


(void)str;
(void)len;


This simple change will get rid of all warnings. I don't mind if the code generation for this header is hidden behind some CLI flag. I just want to get rid of the build warnings that distract me away from real issues in my codebase.

Vinícius dos Santos Oliveira <vinipsmaker>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by haible (Posted a comment)
  • -email is unavailable- added by vinipsmaker (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-07-08 haible StatusNone Fixed
        Assigned toNone haible
        Open/ClosedOpen Closed
        Summary-Wunused-parameter] -Wunused-parameter

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code