Nested Comments in C -- A recent experience

Jim Harkins jharkins at sagpd1.UUCP
Tue Mar 13 07:09:32 AEST 1990


In article <1990Mar11.065712.9798 at usenet.ins.cwru.edu> crds at pyrite.som.cwru.edu (Glenn A. Emelko) writes:
#Well, for once in a long while I've got a few cents to throw in.  Just got done
#spending 3 hours looking for a "bug" which turned out not to be a "bug" at all;
#rather it went undetected as a programming error BECAUSE our C compiler doesn't
#handle nested comments (like most C compilers don't).  The code looked like the
#example below (not the actual code, but similar):
#
#      function(arg1,arg2) {
#        int a,b,c;
#        a=arg1*arg2+3;     /* Oops, we're going to forget to close this comment
#        b=arg1+2*arg2;     /* Guess what, this line never gets executed */
#        c=a+b;
#        return(c);         /* Here's the bogus results, Mr. caller */
#      }
#
#Unfortunately, we spent very little time suspecting that "function" didn't work
#properly, because it was so simple!

Sorry Charlie, but if part of your testing doesn't involve testing each low-
level function individually, especially the "simple" ones, you have much more
serious problems to worry about than nested comments.


-- 
jim		jharkins at sagpd1

"My hope is that we can use tariffs to force Japan to open their markets to
 imported goods.  My fear is I'll be forced to buy lousy American made stuff."



More information about the Comp.lang.c mailing list