Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #7013
| 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 16:19 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <itq90d$onb$1@dont-email.me> (permalink) |
| References | (6 earlier) <5fa0718f-c308-450c-ac3b-b71c0638dc1e@r14g2000yqr.googlegroups.com> <itodld$67u$1@dont-email.me> <itoekf$9n3$1@hoshi.visyn.net> <itoib9$5v0$1@dont-email.me> <1a99fc9d-66cc-4d00-aa63-211b978a7693@p13g2000yqh.googlegroups.com> |
* Francois Duranleau, on 21.06.2011 14:03: > On Jun 20, 6:46 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach > +use...@gmail.com> wrote: >> * Kai-Uwe Bux, on 20.06.2011 23:38: >> >>> Alf P. Steinbach /Usenet wrote: >> >>>> * Francois Duranleau, on 20.06.2011 22:29: >> >>>>> 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. ;-) > > Well, actually, it is covered by this point: > > "- 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)" > > although not very clearly. You have that backwards. In the example above, an `A` object is accessed as a `double`. A `double` is not an aggregate or union. But presumably you would not have posted the article I'm replying to now, if you agreed with that. However, even if it seems to you to be the other way around, consider that the standard's list only works one way, while later on in the standard, a two way conversion is defined -- one of those 2 directions is necessarily missing. 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