public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Warning Behavior
@ 2005-08-23  6:55 Ivan Novick
  2005-08-23  7:09 ` Paolo Bonzini
  2005-08-23  8:40 ` Andreas Schwab
  0 siblings, 2 replies; 4+ messages in thread
From: Ivan Novick @ 2005-08-23  6:55 UTC (permalink / raw)
  To: gcc

Hello,

How come the following code would not be considered a Warning?

Surely there is no possible way this would be intentional?

if (x<4);
	x++;

Cheers,
Ivan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Warning Behavior
  2005-08-23  6:55 Warning Behavior Ivan Novick
@ 2005-08-23  7:09 ` Paolo Bonzini
  2005-08-23  8:40 ` Andreas Schwab
  1 sibling, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2005-08-23  7:09 UTC (permalink / raw)
  To: GCC Development, Ivan.Novick

Ivan Novick wrote:
> Hello,
> 
> How come the following code would not be considered a Warning?
> 
> Surely there is no possible way this would be intentional?
> 
> if (x<4);
> 	x++;

When you consider macro expansion, it could:

#if SIZEOF_LONG == 4
#define WARN_FOR_BIG_VALUES \
   printf ("hey, x is too big, keeping low bits only!")
#else
#define WARN_FOR_BIG_VALUES /* nothing */
#endif

...

long f (long long x)
{
   if (x > LONG_MAX)
     WARN_FOR_BIG_VALUES;

   return x & LONG_MAX;
}

(I'm not saying this is good code).

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Warning Behavior
  2005-08-23  6:55 Warning Behavior Ivan Novick
  2005-08-23  7:09 ` Paolo Bonzini
@ 2005-08-23  8:40 ` Andreas Schwab
  2005-08-23 13:34   ` jlh
  1 sibling, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2005-08-23  8:40 UTC (permalink / raw)
  To: Ivan Novick; +Cc: gcc

Ivan Novick <Ivan.Novick@makoglobal.com> writes:

> How come the following code would not be considered a Warning?

Try -Wextra.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Warning Behavior
  2005-08-23  8:40 ` Andreas Schwab
@ 2005-08-23 13:34   ` jlh
  0 siblings, 0 replies; 4+ messages in thread
From: jlh @ 2005-08-23 13:34 UTC (permalink / raw)
  To: gcc

[-- Attachment #1: Type: text/plain, Size: 336 bytes --]

Andreas Schwab wrote:

> Try -Wextra.

Ah thanks!  I have already lost time several times due to this
almost invisible mistake and I didn't know -Wextra would catch it.
However, it seems to only work for the C compiler, not for C++.

(Using GCC 3.4.4)

(Oops, sorry Andreas, I actually meant to only send the message
to the list)

jlh


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 256 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-08-23 12:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-23  6:55 Warning Behavior Ivan Novick
2005-08-23  7:09 ` Paolo Bonzini
2005-08-23  8:40 ` Andreas Schwab
2005-08-23 13:34   ` jlh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).