X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f To: Dong Soo Kim CC: djgpp AT delorie DOT com In-reply-to: (message from Dong Soo Kim on Sun, 31 Mar 2002 18:24:52 +1000 (EST)) Subject: Re: g++ Warnings References: Message-Id: From: Eli Zaretskii Date: Sun, 31 Mar 2002 12:24:56 -0500 Reply-To: djgpp AT delorie DOT com > From: Dong Soo Kim > Date: Sun, 31 Mar 2002 18:24:52 +1000 (EST) > > > It would be a very Bad Idea (tm) for GCC to flag those cases, since > > they are widely used to shut up compiler warnings about variables > > which the compiler things are used before they are initialized. > > (Compilers can err about this because they don't understand what > > range of values can certain variables have, and thus don't know what > > conditions could fire under what circumstances.) > > out of curiosity, could you give some examples of occasions you'd need to > use that technique? Here's one trivial example (I didn't actually try to compile it with "-Wall", so it might be that latest compilers are smarter than I think; but you get the idea): int foo (int arg) { int i; if (arg > 5) i = arg * 2; if (arg > 6) { i += 8; return i; } return arg + 5; } Here, the second if clause is never entered unless arg > 5, which means i is initialized. But the compiler might not know that, so it will complain.