Errors aren't that simple

Jacob Gore jacob at gore.com
Fri Mar 2 12:12:05 AEST 1990


/ comp.lang.c / billwolf%hazel.cs.clemson.edu at hubcap.clemson.edu (William Thomas Wolfe, 2847 ) / Mar  1, 1990 /
>    The [AT&T long distance netrowk] crash apparently was caused by a
>    programmer who used a "break" 
>    within an if (which itself was within a switch) for the purpose of
>    exiting the if; the real result was to exit the switch instead.

So what else is new?  In the following Ada code the "exit" will exit the
loop instead of the 'if' statement:

	loop
		...
		if ... then
			...
			exit;
		end if;
		...
	end loop;

In C, 'break' exits switches and loops.  Not ifs.

>    If C provided a case statement rather than a switch..break system, then
>    the error would most likely have been prevented.

unless the whole thing was enclosed in a loop, which would be exited
instead of the 'if'.

Jacob
--
Jacob Gore		Jacob at Gore.Com			boulder!gore!jacob



More information about the Comp.lang.c mailing list