[comp.lang.c] Problem using VAX C

ber@astbe.UUCP (H.Bernau) (08/18/89)

We are having a problem using VAX C.

Chapter 5.5.3 (Equality Operators) of the manual (Guide to VAX C, V2.3) says
that "you can compare a pointer or adress with an integer...".

K&R allows this too.

But the problem appears, when you have an array of integers and you want to
compare one element with an integer. If you forget to specify the index
a UNIX C compiler normally gives a warning message (I'm very happy about that
fact :-) ). The VAC C compiler neither gives a warning nor an error :-(

For example, the folling piece of code will compile without any errors/warnings
using VAX-C (vcc under ULTRIX or cc under VMS):

    main() {

	short j;
	short a[10];

	if( a == j) {
	    ;
	 }
    }


Does anyone knows how to detect these sort of things?

Please mail me, I'll post a summarize to the net.

Thanks
-------------------------------------------------------------------------------
|   Rolf Bernau               |
|   GEI Software Technik mbH  |  Berlin:             astbe!ber
|   Hohenzollerndamm 150      |  USA:                ...!pyramid!tub!astbe!ber
|   1000 Berlin 33            |
|   West-Germany              |
-------------------------------------------------------------------------------

ber@astbe.UUCP (H.Bernau) (08/25/89)

One week ago I wrote:

> We are having a problem using VAX C.
> [stuff deleted]
> For example, the folling piece of code will compile without any 
> errors/warnings using VAX-C (vcc under ULTRIX or cc under VMS):
>     main() {
> 
> 	short j;
> 	short a[10];
> 
> 	if( a == j) {
> 	    ;
> 	 }
>    }

> Does anyone knows how to detect these sort of things?

I'm sorry that I did't RTFM. But I searched for this error the whole day so
that I couldn't resist to post my request. Following the signature is a
summarize of the response I got.

Thanks again to all who gave help.
-------------------------------------------------------------------------------
|   Rolf Bernau               |
|   GEI Software Technik mbH  |  Berlin:             astbe!ber
|   Hohenzollerndamm 150      |  USA:                ...!pyramid!tub!astbe!ber
|   1000 Berlin 33            |
|   West-Germany              |
-------------------------------------------------------------------------------


Larry Jones uunet!sdrc!scjones
Steve Summit scs@adam.pika.mit.edu
Jim Barbour barbour@ncar.UCAR.EDU
Jerry Leichter leichter@CS.YALE.EDU 

They told me to use the option /STANDARD=PORTABLE on VMS. The corresponding
option for the ULTRIX vcc is -V standard. That works fine indeed. 
----
bill davidsen (davidsen@crdos1.crd.GE.COM)
> Use another compiler. Seriously, this is a matter of "quality of
> implementation" and philosophy. I like a compiler which requires setting
> an option somehow (what I would call the pickey option) to warn me about
> things which are legal but often misused.

Another compiler isn't necessary (see the above).
-- 
Walter Murray (..hplabs!hpda!walter)
>  1.  Use an ANSI-conforming compiler when you have access to one.
>      A conforming compiler will be required to produce a diagnostic
>      on this error.
>  2.  Use lint.  I think most versions of lint will catch the problem.

1. Not necessary (see above)
2. Using lint will work. But if you use some features of VAX C (unfortunatly we
   must) lint will give so many messages that I think the one I want to see
   will get lost.
-------------
Jim Patterson decvax!utzoo!dciem!nrcaer!cognos!jimp
> A company called IPT sells a lint-like product called LINT-PLUS.
> (It used to be called TRACER). It runs under VMS as well as a
> number of other non-unix platforms, and more or less understands
> VMS C. It should be able to locate missing casts as well as
> various other potential problems.
> IPT's address is
>     Information Processing Techniques Corporation
>     1096 East Meadow Circle
>     Palo Alto, California 94303
>     Phone: (415) 494-7500 in U.S.A.
> (This is fairly old, but I can't locate a more up to date one).