[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference decwet::visual

Title:Microsoft Visual C++ bug reports and kits
Notice:Register in Topic 2. 5.Last for latest Kit
Moderator:DECWET::THOMASN
Created:Tue May 17 1994
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:521
Total number of notes:2938

456.0. "No syntax error on C++ comment with /Za" by SMURF::GAF (Jerry Feldman, Unix Dev. Environment, DTN:381-2970) Tue Feb 04 1997 13:42

    This is more of a question than a problem statement.
    
    We observed that the VC++ compiler, when compiling a C program with the
    /Za switch, the C compiler does not complain if that C program contains 
    C++ style comments, which are illegal in ANSI (89).
    
    The switches I am using for this test are:
    /nologo /Gt0 /Za /W3 /GX /D "WIN32" /D "_CONSOLE" /YX /c
    
    the code is just a simple test program which I inserted a  C++ style
    comment. I would have expected that the /Za switch would cause the line
    containing the C++ style comment to yield a syntax error.,
T.RTitleUserPersonal
Name
DateLines
456.1Command line results same sameSMURF::GAFJerry Feldman, Unix Dev. Environment, DTN:381-2970Tue Feb 04 1997 14:044
    Just to add a bit more. Went to the command line, using just the /Za
    switch on version 10.10.6079 and 11.10.6332.
    
    Again, no warnings. I would expect a syntax error in ANSI mode.
456.2DECCXL::OUELLETTEWed Feb 05 1997 08:599
I would expect a diagnostic and would much prefer a warning to an error.

With the C 1989 standard oddities like:

	a = b //* a commment */ c;

could appear in C programs.  (Although this is a strange thing to do.)

R.
456.3Internesting behavior in roland's exampleSMURF::GAFJerry Feldman, Unix Dev. Environment, DTN:381-2970Thu Feb 13 1997 06:2723
    Re .2
    Roland retorts:
    >I would expect a diagnostic and would much prefer a warning to an
    >error.
    In your example,
    a = b //* a commment */ c;
    A non-compliant program interpreting the // as a comment will receive
    an error that the next line is missing a ";".
    An ANSI compliant program should treat the /* comment as a real comment
    and evaluate the expression as a = b / c;
    
    VC++5.0 with the /Za switch evaluates "a = b / c;".
    VC++5.0 without the /Za switch complains about the semicolon. 
    
    DECC with -std1 behaves as /Za, with -std0 and -std, behaves as VC++
    without the /Za
    
    In the expression, a = b // c;
    
    VC++5.0 treats the // as a comment. I would have expected that an ansi
    compliant compiler would complain that the // is an invalid expression
    or something like that.
    
456.4DECC::OUELLETTEThu Feb 13 1997 11:511
Credit for the interesting example goes to Rich Peterson.
456.5The culprit is exposed/SMURF::GAFJerry Feldman, Unix Dev. Environment, DTN:381-2970Mon Feb 17 1997 10:082
    RE:Credit for the interesting example goes to Rich Peterson.
    Thanks for exposing the culprit.