Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #6210
| From | Vaclav Haisman <v.haisman@sh.cvut.cz> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: unions |
| Date | 2011-06-04 20:13 +0200 |
| Organization | Czech Technical University |
| Message-ID | <4DEA75DF.6010402@sh.cvut.cz> (permalink) |
| References | <iscfn1$keo$8@reader1.panix.com> <isdrr3$urc$1@node2.news.atman.pl> |
Edek wrote, On 4.6.2011 19:59: > Am I missing something about them? I >> started to have deep doubts about what I thought I knew. >> > > Other things aside, by the standard unions are the only > possibility to alias two non-char types without breaking > optimisations. Maybe void* is another and a couple of > other strange cases. Don't ask me about where it is in the > standard; I just know that it is a pain to find bugs > caused by wrong casting coupled with unpredictable optimisation > results (UB caused by casts really, unions are safe). Unions are not safe. You cannot write using one union member and read using another. It is only GCC extension that it works but the standard does not allow it, AFAIK. -- VH
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
unions Ruben Safir <ruben@mrbrklyn.com> - 2011-06-04 05:26 +0000
Re: unions Ian Collins <ian-news@hotmail.com> - 2011-06-04 17:38 +1200
Re: unions Ruben Safir <ruben@mrbrklyn.com> - 2011-06-04 05:45 +0000
Re: unions Ian Collins <ian-news@hotmail.com> - 2011-06-04 18:04 +1200
Re: unions Ruben Safir <ruben@mrbrklyn.com> - 2011-06-04 06:13 +0000
Re: unions Öö Tiib <ootiib@hot.ee> - 2011-06-04 04:54 -0700
Re: unions Edek <edek.pienkowski@gmail.com> - 2011-06-04 19:59 +0200
Re: unions Vaclav Haisman <v.haisman@sh.cvut.cz> - 2011-06-04 20:13 +0200
Re: unions Edek <edek.pienkowski@gmail.com> - 2011-06-04 22:34 +0200
Re: unions Vaclav Haisman <v.haisman@sh.cvut.cz> - 2011-06-05 07:29 +0200
Re: unions Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-06-09 09:19 +0000
Re: unions Keith <kbelder@gmail.com> - 2011-06-09 11:17 -0700
Re: unions Victor Bazarov <v.bazarov@comcast.invalid> - 2011-06-09 14:29 -0400
Re: unions Edek <edek.pienkowski@gmail.com> - 2011-06-10 13:16 +0200
csiph-web