Proposal: Warnings for unnecessary warning suppression

Magnus Ihse Bursie magnus.ihse.bursie at oracle.com
Thu Mar 6 15:45:26 UTC 2025


On 2025-03-04 07:16, Joseph D. Darcy wrote:

> Another consideration is being able to successfully compile a code 
> base under multiple javac versions. A particular important instance of 
> this is boot strapping the JDK :-)
>
> Cases that have occurred in the past that would make such a discipline 
> challenging include:
>
> * Correctness fixes to the warning computation
> * Expanding (or narrowing) the scope of what the warning looks for 
> (e.g. the serial warning)
>
> So perhaps "messages" about "unnecessary warning suppression" should 
> be relayed somewhat outside of the existing warnings mechanism.
>
I concur. Earlier versions of gcc complained if you wanted to disable a 
warning like -Wno-new-fancy-warning, making it a complete mess to get 
things to compile cleanly for different versions. Later versions changed 
this into a policy where command line arguments like 
-Wno-dont-recognize-this-warning are just silently ignored -- unless 
another warning is triggered on that file, in which case gcc *also* 
emits a warning about an unknown warning. I think this is a reasonably 
pragmatic approach.

But having warning suppression that does not make sense for a given 
compiler is not necessary a problem, and if it should be flagged, it 
should be something you opt into, and possibly, as Joe suggests, somehow 
lie outside normal warnings.

/Magnus



More information about the compiler-dev mailing list