[comp.lang.c] Is this correct a=/* comment */b;

pat@ctycal.UUCP (Patrick Woo) (02/05/91)

I have the following line in some third party source code

a=/* This is a comment */b;

it compile using VAX C and fails with Green Hill C
Just wondering whether the compiler should read the line as

a = /*comment*/ b;

or

a =/ *comment ...;

-- 
  Patrick Woo                  pat%ctycal@cpsc.ucalgary.ca
  Land Information Services                 or
  The City of Calgary       ...{alberta,ubc-cs,uunet}!calgary!ctycal!pat

steve@taumet.com (Stephen Clamage) (02/06/91)

pat@ctycal.UUCP (Patrick Woo) writes:

>a=/* This is a comment */b;
>Just wondering whether the compiler should read the line as

>a = /*comment*/ b;
>or
>a =/ *comment ...;

Under Standard (ANSI/ISO) C, =/ is not a token, so the only valid reading is
	a = /*comment*/ b;

In K&R1 (1978), =/ and friends are listed as already obsolete -- 13 years
ago!  Some compilers continued to accept =/ as a token, but marked them
with a warning.

If a compiler (in violation of the Standard) now chooses to accept =/ as a
valid token, then the rule about "longest string which could be a token"
applies, and the compiler must interpret the example as
	a =/ *comment */ b;
which contains at least a syntax error.  I don't see why any compiler
should accept =/ and friends any more.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com

scs@adam.mit.edu (Steve Summit) (02/07/91)

In article <532@ctycal.UUCP> pat@ctycal.UUCP (Patrick Woo) writes:
> I have the following line in some third party source code
> a=/* This is a comment */b;

In article <584@taumet.com> steve@taumet.com (Stephen Clamage)
answers correctly and then wonders:
> ...why any compiler should accept =/ and friends any more
since they were
> ...listed as already obsolete -- 13 years ago!

What I am wondering (pardon my French) is which pencil-necked
"third party" cretin wrote that shit in the first place?  I'm not
yelling at you, Pat, but please tell us exactly who, so we can
string him up by his thumbnails.  There are at most two places
for code like

	a=/* This is a comment */b;

neither of them any good:

     1.	the obfuscated C contest, and
     2.	these silly discussions.

Anyone who sticks a comment like that in anything even remotely
resembling production code should probably be dragged out behind
the barn on an icy, moonless night and put out of his misery with
a 12-gauge like the pathetic dying mongrel he is.

                                            Steve Summit
                                            scs@adam.mit.edu

gwyn@smoke.brl.mil (Doug Gwyn) (02/08/91)

In article <1991Feb7.032512.20133@athena.mit.edu> scs@adam.mit.edu writes:
>Anyone who sticks a comment like that in anything even remotely
>resembling production code should probably be dragged out behind
>the barn on an icy, moonless night and put out of his misery with
>a 12-gauge like the pathetic dying mongrel he is.

My guess is that it was part of a C validation suite, for which it
would be a most appropriate piece of code.