Path: utzoo!censor!geac!torsqnt!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!asuvax!noao!arizona!dave From: dave@cs.arizona.edu (David P. Schaumann) Newsgroups: comp.lang.c Subject: Re: Nested Comments in C -- A recent experience Message-ID: <133@caslon.cs.arizona.edu> Date: 11 Mar 90 18:01:05 GMT References: <236100027@prism> <1414@amethyst.math.arizona.edu> <1523@wacsvax.OZ> <1990Mar11.065712.9798@usenet.ins.cwru.edu> Organization: U of Arizona CS Dept, Tucson Lines: 36 In article <1990Mar11.065712.9798@usenet.ins.cwru.edu>, crds@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 ^^^^^^^^^^^^^^^^^ What's the difference? |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 */ | } [ description of search for bug deleted ] |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. | |Glenn Emelko The C compiler here (gcc) has an option which will warn of a comment start sequence (/*) embedded in a comment. I agree that this should have been caught by the compiler, but I think adding nested comments is the wrong solution. Rather, the compiler should always flag the occurance of /* within a comment unless explicitly told to shut up about it. Does anyone know what ANSI says about this? Dave Schaumann dave@cs.arizona.edu