This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: middle-end/9725: Invalid dependency determination


But why is the structure incompatible?

"... 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), ..."

The structure does include two fields of type 'unsigned' (the fact that
they are bit fields doesn't alter their type as I view it). And, as
already asked, when the second store is deemed non-conflicting, then why
isn't the first store, too? And, with respect to the other mail - short
of not using this logic - how do I access sub-fields of a built-in type
(while the code I have to fix for others to overcome the optimizer
problem uses ints, I'm really more interested in accessing sub-fields of
floating point types (other than through memcpy-ing the float into and
afterwards out of a structure)?

Thanks, Jan

>>> Wolfgang Bangerth <bangerth at ticam dot utexas dot edu> 19.02.03 17:59:46
>>>

> struct s {
> 	unsigned f1:16;
> 	unsigned f2:16;
> };
> 
> void test(unsigned *pf, unsigned x, unsigned y) {
> 	unsigned f;
> 
> 	((struct s*)&f)->f1 = x;
> 	((struct s*)&f)->f2 = y;
> 	*pf = f;
> }

You still try to access the bits of the unsigned int variable f through

the bits of the incompatible structure s. Short answer: don't do that.

W.

-------------------------------------------------------------------------
Wolfgang Bangerth             email:           
bangerth at ticam dot utexas dot edu 
                              www:
http://www.ticam.utexas.edu/~bangerth/ 



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]