Re: [Algorithms] How to get 3dvector largest coordinate index?
Brought to you by:
vexxed72
From: Gino v. d. B. <gin...@gm...> - 2009-03-06 13:01:07
|
Aliasing is having multiple references to the same memory location. That's exactly what's happening when type punning. An example union Pun { float f; int32_t i; }; ... Pun pun; pun.f = x; int32_t result = pun.i; According to the C++ standard a compiler would be allowed to fetch pun.i before pun.f has been written and the result would contain garbage instead of the bit-representation of x. I do not see this happening with gcc, so either gcc's optimizer has a flaw, or the developers deliberately chose not to exploit type strictness in this case. I assume the latter. liam mail wrote: > > I am sorry I do not understand why you think this is to do with > aliasing? The standard guarantees that union fields occupy the same > space yet that only one maybe active. > > 9.5 Unions [class.union] > 1 In a union, at most one of the data members can be active at any > time, that is, the value of at most one of > the data members can be stored in a union at any time. [Note: one > special guarantee is made in order to > simplify the use of unions: If a POD-union contains several > POD-structs that share a common initial > sequence (9.2), and if an object of this POD-union type contains one > of the POD-structs, it is permitted to > inspect the common initial sequence of any of POD-struct members; see > 9.2. ] > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > ------------------------------------------------------------------------ > > _______________________________________________ > GDAlgorithms-list mailing list > GDA...@li... > https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list |