[comp.lang.c] unions and volatile qualifiers

ksb@j.cc.purdue.edu (Kevin Braunsdorf) (04/10/88)

-------

All the members of this union should be tagged as being volatile.

	union {
		int oi;
		char oc;
	} u;
	int *pi;

	pi = & u.oi;			/* should be a comment || warning */

You see why they cannot be ordinary in the union?

Another case:
	union {
		noalias int ei;		/* should be a comment || warning */
		char oops;
	} u2;

the int is not exclusive in the union, it cannot be.

Do we all agree that a volatile is needed here (in unions)?

I'll discuss this through mail with anyone who cares.

kayessbee		pur-ee!ksb	ksb@j.cc.purdue.edu

nevin1@ihlpf.ATT.COM (00704a-Liber) (04/12/88)

In article <6891@j.cc.purdue.edu> ksb@j.cc.purdue.edu.UUCP (Kevin Braunsdorf) writes:
|All the members of this union should be tagged as being volatile.
|
|	union {
|		int oi;
|		char oc;
|	} u;
|	int *pi;
|
|	pi = & u.oi;			/* should be a comment || warning */

|You see why they cannot be ordinary in the union?

No.  What volatile means is that something besides this program can modify
this variable (such as a hardware interrupt, signal handler, etc.).
-- 
 _ __			NEVIN J. LIBER	..!ihnp4!ihlpf!nevin1	(312) 510-6194
' )  )				"The secret compartment of my ring I fill
 /  / _ , __o  ____		 with an Underdog super-energy pill."
/  (_</_\/ <__/ / <_	These are solely MY opinions, not AT&T's, blah blah blah