Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: Derek Jones Newsgroups: comp.compilers Subject: Re: Union C++ standard Date: Sun, 28 Nov 2021 12:51:14 +0000 Organization: Compilers Central Lines: 16 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <21-11-009@comp.compilers> References: <21-11-004@comp.compilers> <21-11-008@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="13223"; mail-complaints-to="abuse@iecc.com" Keywords: C, standards Posted-Date: 28 Nov 2021 12:13:12 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com In-Reply-To: <21-11-008@comp.compilers> Content-Language: en-US Xref: csiph.com comp.compilers:2756 David, > In C, type-punning via unions is allowed (i.e., fully defined behaviour That is not true. Writing into one member and then reading from another member is undefined behavior. There is a special dispensation for what is known as a common initial sequence: sentence 1029 http://c0x.shape-of-code.com/6.5.2.3.html > in the standards), but not in C++ where the language is expected to > enforce higher-level aspects of the data. This is a meaningless statement.