🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #404

disabling warnings in dead code

#404
From: Roland McGrath
Date: Tue, 14 Apr 1992 17:28
17 lines
1160 bytes
It would be nice to not issue some kinds of warnings for completely dead code.

I have, for example:

      if (sizeof (cccc) > 4)
	cccc |= cccc << 32;

If CCCC is 32 bits, gcc 2.1 -Wall issues a warning that the shift count is
too large.  That's true; the code is wrong.  But it will never be executed.
If compiled with sizeof (CCCC) == 8, for example (i.e., cccc is declared
long long instead of long), however, the code will be executed, and it will
be correct.

Since cpp cannot do things like sizeof, there is no way to avoid having the
known-erroneous code presented to the compiler.  But gcc does this sort of
optimization well, so the dead statements never actually produce any code,
so using them is fine.  Only the warnings are annoying.
Technical Details
Message-ID: <9204150128.AA04221@churchy.gnu.ai.mit.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!gnu.ai.mit.edu!roland

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!gnu.ai.mit.edu!roland
From: roland@gnu.ai.mit.edu (Roland McGrath)
Subject: disabling warnings in dead code
Message-ID: <9204150128.AA04221@churchy.gnu.ai.mit.edu>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Tue, 14 Apr 1992 17:28:36 GMT
Approved: bug-gcc@prep.ai.mit.edu
Lines: 18