Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!ukc!reading!cf-cm!cybaswan!iiitsh From: iiitsh@cybaswan.UUCP (Steve Hosgood) Newsgroups: comp.std.c Subject: Re: Interpretation of volatile - two questions Message-ID: <1644@cybaswan.UUCP> Date: 21 Mar 90 09:55:29 GMT References: <2604A628.8521@paris.ics.uci.edu> <1990Mar19.165931.22758@utzoo.uucp> Reply-To: iiitsh@cybaswan.UUCP (Steve Hosgood) Organization: Institute for Industrial Information Technology Lines: 24 In article <1990Mar19.165931.22758@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: >In article <2604A628.8521@paris.ics.uci.edu> rfg@paris.ics.uci.edu (Ronald Guilmette) writes: >> struct s { >> char c1; >> volatile char c2; >> }; >>... >> c = memory_mapped_device_p->c1; >>... >>does the standard (a) permit, (b) require, or (c) prohibit the assignment >>statement shown to access the c2 field of the "struct s" pointed to by >>memory_mapped_device_p? > >The standard, by and large, is silent about the *details* of how volatile >works. Necessarily so; it's very machine-specific. Suppose your machine's >bus only does word accesses, and it *cannot* access c1 without also >touching c2? In this latter case, surely the 'expected' compiler action should be to print an error message to the tune of 'cannot generate code on this machine'. After all, it can't be right for a compiler to generate code that does an invisible access to a volatile - even if it can't help it. Steve