Newsgroups: comp.lang.c Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!usenet.ins.cwru.edu!pyrite.som.cwru.edu!crds From: crds@pyrite.som.cwru.edu (Glenn A. Emelko) Subject: Nested Comments in C -- A recent experience Message-ID: <1990Mar11.065712.9798@usenet.ins.cwru.edu> Sender: news@usenet.ins.cwru.edu Reply-To: crds@pyrite.som.cwru.edu (Glenn A. Emelko) Organization: WSOM CSG, CWRU, Cleve., OH References: <236100027@prism> <1414@amethyst.math.arizona.edu> <1523@wacsvax.OZ> <4320@daffy.cs.wisc.edu> Date: Sun, 11 Mar 90 06:57:12 GMT 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! The compiler didn't complain about it, and we had no reason to suspect that it wasn't returning the proper value - in fact when we looked at what it returned we STILL were baffled - so much in fact that we decided to look at the .asm file to find the nasty stack corruption that had to be causing our problem (or so we thought)... and that's where I noticed that a whole line of code was missing in the .asm code; I did a double-take and then looked REAL carefully at the C code and spotted the missing end-of-comment. Up until now I had no opinion on this matter; however things have changed. If the C compiler understood nested comments it would FORCE programmers to match them, preventing wasted hours of debugging on annoying problems like the above at the expense of a few milliseconds of additional compile time. Anyone else? Glenn Emelko