About switch case statements...

Don nospam at nospam.com
Mon Nov 16 02:51:23 PST 2009


Walter Bright wrote:
> Don wrote:
>> I frequently use fall-through myself, but having looked at this 
>> sample, I bet I don't use it nearly as much as I thought: again, 
>> "frequently" probably means "about 1% of the time". But I *know* I've 
>> had bugs from leaving out 'break'.
> 
> I poked through the optimizer code, gloop.c and gflow.c, and right away 
> saw several uses of it.

You're right, there's one at the top of gloop. And this one in gflow is 
a doozy.


	case OPvptrfptr:
	case OPcvptrfptr:
	    if ((flowxx == AE) && n->Eexp)
		vec_orass(KILL,vptrkill);
	    break;

	default:
	    if (OTunary(op))
	    {
#if TX86
	case OPind:				// most common unary operator
		accumaecpx(n->E1);
#ifdef DEBUG
		assert(!OTassign(op));
#endif
#else
		accumaecpx(n->E1);
		if (OTassign(op))
		    t = Elvalue(n);
#endif
	    }
	    else if (OTbinary(op))
	    {
		if (OTrtol(op) && ERTOL(n))
		{   accumaecpx(n->E2);


That's not fall-through, one case is *inside* the 'if' clause of another 
one!! Wow. Do you really want to encourage that sort of thing?




More information about the Digitalmars-d mailing list