This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Can the gcc 3.x code be cleaned up to avoid unnecessary warning m


On Wed, 29 May 2002, Joe Buck yowled:
> void proc(int foo)
> {
> 	int flag;
> 	if (foo) {
> 		flag = result_of_some_boolean_function();
> 	}
> 	some_other_code();
> 	if (foo) {
> 		if (flag)
> 			do_something();
> 		else
> 			do_something_else();
> 	}
> }
> 
> gcc will complain that flag can be used uninitialized, which is not
> correct.

One hopes that when SSA gets used more heavily, GCC's tracking of
variable-lifetime information will get good enough to detect this
particular case, at least.

(But of course if the `foo's are different but the first conditional is
always true when the second is true, I'd not expect any C compiler, no
matter how smart, to realise that flag was only used initialized.)

-- 
`What happened?'
                 `Nick shipped buggy code!'
                                             `Oh, no dinner for him...'


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]