Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #6985
| From | "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Strict aliasing and buffer handling |
| Date | 2011-06-21 00:46 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <itoib9$5v0$1@dont-email.me> (permalink) |
| References | (4 earlier) <59682659-868a-4498-b5bc-ef53f6a74105@k6g2000yqc.googlegroups.com> <ito9h7$6jr$1@dont-email.me> <5fa0718f-c308-450c-ac3b-b71c0638dc1e@r14g2000yqr.googlegroups.com> <itodld$67u$1@dont-email.me> <itoekf$9n3$1@hoshi.visyn.net> |
* Kai-Uwe Bux, on 20.06.2011 23:38: > Alf P. Steinbach /Usenet wrote: > >> * Francois Duranleau, on 20.06.2011 22:29: >>> On Jun 20, 4:16 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach >>> +use...@gmail.com> wrote: >>>> >>>> Strict aliasing is a g++ thing, not a standard C++ thing: the standard >>>> is The Wrong Place to look for info about strict aliasing, it's not >>>> there. >>> >>> Quoting 3.10-15 from the C++ standard (2003): >>> >>> "If a program attempts to access the stored value of an object through >>> an lvalue of other than one of the following >>> types the behavior is undefined): >>> ? the dynamic type of the object, >>> ? a cv-qualified version of the dynamic type of the object, >>> ? a type that is the signed or unsigned type corresponding to the >>> dynamic type of the object, >>> ? a type that is the signed or unsigned type corresponding to a cv- >>> qualified version of the dynamic type of the object, >>> ? an aggregate or union type that includes one of the aforementioned >>> types among its members (including, recursively, a member of a >>> subaggregate or contained union), >>> ? a type that is a (possibly cv-qualified) base class type of the >>> dynamic type of the object, >>> ? a char or unsigned char type." >>> >>> So what I am reading here? >> >> A flawed attempt at enumerating the ways, which attempt was/is presumably >> the perceived rationale for g++ "strict aliasing". > > What is the flaw? Just as an example that the above list does not cover everything, the intro to classes says that if class A is a POD, and its first member is a double, say, then if you have a pointer to an A then you can reinterpret_cast it to pointer to double to access that first member. It's for C compatibility. And that's not covered by the list, i.e. there's at least one engine stutter: the list says it's UB, later on in the standard it's said to be well-defined. ;-) I don't know exactly what the flaw or set of flaws is, in the sense of not knowing exactly why an engine stutters (i.e., cause). Perhaps just the attempt to cover everything. It has been discussed at length, many times, as I recall without any good consensus, but it hould be possible to find those discussions. > I don't think the flaw is obvious (it isn't to me). As evidence (not that it > isn't flawed, but that's it is not _obviously_ flawed) I would offer that an > adapted version of the list made it into n3291 as 3.10/10. So, it appears, > the committee did not see a flaw; or is there a core issue about this that I > am unaware of? or is the flaw just fixed by passing to glvalues etc.? The committee is not perfect, nor does it have the capacity to deal with everything. I think there's a lot of flawed stuff migrating straight over into the new standard. Cheers & hth., - Alf -- blog at <url: http://alfps.wordpress.com>
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Strict aliasing and buffer handling Francois Duranleau <xiao.bai.xiong@gmail.com> - 2011-06-20 09:59 -0700
Re: Strict aliasing and buffer handling "Paul" <pchristor@yahoo.co.uk> - 2011-06-20 19:39 +0100
Re: Strict aliasing and buffer handling Francois Duranleau <xiao.bai.xiong@gmail.com> - 2011-06-20 11:56 -0700
Re: Strict aliasing and buffer handling Leigh Johnston <leigh@i42.co.uk> - 2011-06-20 20:12 +0100
Re: Strict aliasing and buffer handling Francois Duranleau <xiao.bai.xiong@gmail.com> - 2011-06-20 12:39 -0700
Re: Strict aliasing and buffer handling Leigh Johnston <leigh@i42.co.uk> - 2011-06-20 20:49 +0100
Re: Strict aliasing and buffer handling "Paul" <pchristor@yahoo.co.uk> - 2011-06-20 21:12 +0100
Re: Strict aliasing and buffer handling Leigh Johnston <leigh@i42.co.uk> - 2011-06-20 21:20 +0100
Re: Strict aliasing and buffer handling "Paul" <pchristor@yahoo.co.uk> - 2011-06-21 10:35 +0100
Re: Strict aliasing and buffer handling Leigh Johnston <leigh@i42.co.uk> - 2011-06-21 12:35 +0100
Re: Strict aliasing and buffer handling "Paul" <pchristor@yahoo.co.uk> - 2011-06-21 12:37 +0100
Re: Strict aliasing and buffer handling "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-06-20 22:16 +0200
Re: Strict aliasing and buffer handling Francois Duranleau <xiao.bai.xiong@gmail.com> - 2011-06-20 13:29 -0700
Re: Strict aliasing and buffer handling "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-06-20 23:27 +0200
Re: Strict aliasing and buffer handling Joshua Maurice <joshuamaurice@gmail.com> - 2011-06-20 14:37 -0700
Re: Strict aliasing and buffer handling "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-06-21 00:31 +0200
Re: Strict aliasing and buffer handling Joshua Maurice <joshuamaurice@gmail.com> - 2011-06-20 19:37 -0700
Re: Strict aliasing and buffer handling Kai-Uwe Bux <jkherciueh@gmx.net> - 2011-06-20 23:38 +0200
Re: Strict aliasing and buffer handling "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-06-21 00:46 +0200
Re: Strict aliasing and buffer handling Francois Duranleau <xiao.bai.xiong@gmail.com> - 2011-06-21 05:03 -0700
Re: Strict aliasing and buffer handling "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-06-21 16:19 +0200
Re: Strict aliasing and buffer handling Francois Duranleau <xiao.bai.xiong@gmail.com> - 2011-06-21 09:08 -0700
Re: Strict aliasing and buffer handling "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-06-22 01:43 +0200
Re: Strict aliasing and buffer handling Joshua Maurice <joshuamaurice@gmail.com> - 2011-06-20 14:49 -0700
Re: Strict aliasing and buffer handling "io_x" <a@b.c.invalid> - 2011-06-21 09:12 +0200
Re: Strict aliasing and buffer handling Ian Collins <ian-news@hotmail.com> - 2011-06-21 20:14 +1200
csiph-web