gcc - Is it guaranteed that Complex Float variables will be 8-byte aligned in memory? -


in c99 new complex types defined. trying understand whether compiler can take advantage of knowledge in optimizing memory accesses. these objects (a-f) of type complex float guaranteed 8-byte aligned in memory?

 #include "complex.h" typedef complex float cfloat;  cfloat a; cfloat b[10];  void func(cfloat c, cfloat *d) {     cfloat e;     cfloat f[10]; } 

note d, question relates object pointed d, not pointer storage itself. and, if assumed aligned, how can 1 sure address passed of actual complex , not cast (non 8-aligned) type?

update 1: answered myself in last comment regarding d pointer. b/c there no way know address assigned parameter of function call, there no way guarantee 8-aligned. solvable via __builtin_assumed_aligned() function.

the question still open other variables.

update 2: posted follow-up question here.

a float complex guaranteed have same memory layout , alignment array of 2 float (§6.2.5). alignment defined compiler or platform. can sure float complex at least aligned float.

if assumed aligned, how can 1 sure address passed of actual complex , not cast (non 8-aligned) type?

if caller passes insufficiently-aligned pointer, that's undefined behavior , bug in code (§6.3.2.3). don't need support (though may choose to).


Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -