Xref: utzoo comp.std.c:4622 comp.lang.c:38016 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!decwrl!adobe!taft From: taft@adobe.com (Ed Taft) Newsgroups: comp.std.c,comp.lang.c Subject: volatile and typedef Message-ID: <13698@adobe.UUCP> Date: 6 Apr 91 21:33:00 GMT Sender: news@adobe.COM Reply-To: taft@adobe.COM Followup-To: comp.std.c Organization: Adobe Systems Incorporated, Mountain View Lines: 40 Consider the following example: typedef int *int_ptr; int_ptr pi; volatile int_ptr vpi; int test() { vpi = pi; return *vpi; } My understanding is that the volatile type qualifier refers only to the variable vpi (used as an lvalue) and not to the thing it points to. I base this on the example given in 3.5.4.1, although that example uses const instead of volatile. Unfortunately, the C compiler on the DECstation 5000 (Ultrix 4.0) apparently thinks otherwise. This compiler does not claim to be ANSI-compliant, but it does support the volatile type qualifier out of necessity. Here are its complaints: ccom: Warning: volatile.c, line 8: illegal pointer combination vpi = pi; ----------^ ccom: Warning: volatile.c, line 9: illegal combination of pointer and integer, op RETURN return *vpi; -------------^ The correct code appears to be generated in spite of the warnings. In contrast to this, gcc accepts the above program without complaint (even with -Wall and -pedantic options). I also cannot get the Ultrix compiler to generate any complaints unless a typedef is involved. Is the compiler wrong to complain about this usage, or does the program really violate the standard in some way? Ed Taft taft@adobe.com ...decwrl!adobe!taft