Article View: comp.std.c
Article #4178Re: Union access
From: Christopher R. Volpe
Date: Wed, 04 Oct 1995 15:35
Date: Wed, 04 Oct 1995 15:35
52 lines
2910 bytes
2910 bytes
In article <44u4uv$c18@lyra.csx.cam.ac.uk>, nmm1@cus.cam.ac.uk (Nick Maclaren) writes: > >I didn't say that it was required to produce a diagnostic. There are >several kinds of illegality in ANSI C that need not be diagnosed. There are two kinds of illegality: The kind that requires a diagnostic (syntax or constraint violation) and the kind that doesn't (undefined behavior). > >|> Even if it detects the error, and generates code, how can you justify >|> any claim about what illegal code "must" do? > >Try 3.1.2.5 "The qualified and unqualified versions of a type are distinct >types that belong to the same type category and have the same representation >and alignment requirements." and footnote 15 "The same representation and >alignment requirements are meant to imply interchangeability as arguments to >functions, return values from functions, and members of unions." Follow on >from there. > Where the above applies, I'd say there is no error to diagnose in the first place. Where there is already an error (of either kind), the above will not save you. >In any case, I was talking about when it FAILS to detect the error! Right, which is why I assumed you were talking about required diagnostics, otherwise you might have said, "when it CHOOSES NOT to detect the error". > >|> >There is actually some dissent about this. Some people hold the view that >|> >implementation-defined behaviour allows the compiler writer to say "if you >|> >use this construction, you will get no error message and your program will >|> >go bananas." This is clearly not what the ANSI committee intended compiler >|> >writers to do :-) >|> >|> Correct, but what exactly is implementation defined in the example you gave? > >Assigning a value to a 'const int *' initial member and reading it as an >'int *' etc. Because these are not compatible types, 3.3.2.3 makes the >effect implementation-defined. If the effect is implementation defined, then there is no error here to speak of, right? "Not strictly conforming" does not imply "erroneous". I still don't see an example of "illegal" code that "must" behave in a particular way. Am I missing something? -- Chris Volpe Phone: (518) 387-7766 (Dial Comm 8*833 GE Corporate R&D Fax: (518) 387-6560 PO Box 8, Schenectady, NY 12301 Email: volpecr@crd.ge.com
Technical Details
Message-ID:
<44u9jl$6o2@rdsunx.crd.ge.com>Path:
arc1-ca.pugleaf.net!bart.crd.ge.com!volpeReferences:
<812736828snz@soliton.demon.co.uk> <44u0jm$9pr@lyra.csx.cam.ac.uk> <44u2h1$362@rdsunx.crd.ge.com> <44u4uv$c18@lyra.csx.cam.ac.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!bart.crd.ge.com!volpe From: volpe@bart.crd.ge.com (Christopher R. Volpe) Newsgroups: comp.std.c Subject: Re: Union access Date: 4 Oct 1995 15:35:17 GMT Organization: GE Corporate Research & Development Sender: volpe@bart (Christopher R. Volpe) Distribution: world Message-ID: <44u9jl$6o2@rdsunx.crd.ge.com> References: <812736828snz@soliton.demon.co.uk> <44u0jm$9pr@lyra.csx.cam.ac.uk> <44u2h1$362@rdsunx.crd.ge.com> <44u4uv$c18@lyra.csx.cam.ac.uk> Reply-To: volpe@ausable.crd.ge.com NNTP-Posting-Host: bart.crd.ge.com