[Bug middle-end/29078] wrong alignment with pragma pack(4)
--- Comment #6 from pinskia at gcc dot gnu dot org 2006-09-14 14:56 --- (In reply to comment #5) > (In reply to comment #3) > And what with such example: > #include > #pragma pack(4) > struct ABC > { > double a; > int b; > bool c; > }; > void Init(double& a) > { a = 17.0; } > int main() > { > ABC A; > ABC B; > int C; > ABC D; > printf("D.a = %f\n", D.a); > Init(D.a); Nope, this testcase is invalid as you are violating the alignment requirement for double pointers. -- pinskia at gcc dot gnu dot org changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29078
[Bug middle-end/29078] wrong alignment with pragma pack(4)
--- Comment #5 from dsiata at poczta dot onet dot pl 2006-09-14 10:46 --- (In reply to comment #3) And what with such example: #include #pragma pack(4) struct ABC { double a; int b; bool c; }; void Init(double& a) { a = 17.0; } int main() { ABC A; ABC B; int C; ABC D; printf("D.a = %f\n", D.a); Init(D.a); printf("D.a = %f\n", D.a); return 0; } There is Bus Error in Init function... -- dsiata at poczta dot onet dot pl changed: What|Removed |Added Status|VERIFIED|UNCONFIRMED Resolution|INVALID | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29078
[Bug middle-end/29078] wrong alignment with pragma pack(4)
--- Comment #4 from dsiata at poczta dot onet dot pl 2006-09-14 08:57 --- (In reply to comment #3) OK. Now I see it's new feature in 4.0 or 4.1 series. I have GPF in similar code but for now I cannot reproduce it on simple case... Thank you. Now I know to not use pack(4) :-) -- dsiata at poczta dot onet dot pl changed: What|Removed |Added Status|RESOLVED|VERIFIED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29078
[Bug middle-end/29078] wrong alignment with pragma pack(4)
--- Comment #3 from pinskia at gcc dot gnu dot org 2006-09-14 08:19 --- (In reply to comment #2) > Because double have to be aligned on 8 on sparc or bus error occurs. > Note that first member of the structure is double. So now I'm not able to > assign any value to D.a. Wrong, wrong, wrong. The compiler knows the alignment is not 8byte aligned so it knows how to generate the code correctly. If that fails then you have a bug with that but the code you gave is currently correct with what GCC gives. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29078
[Bug middle-end/29078] wrong alignment with pragma pack(4)
--- Comment #2 from dsiata at poczta dot onet dot pl 2006-09-14 08:14 --- Subject: Re: wrong alignment with pragma pack(4) U¿ytkownik pinskia at gcc dot gnu dot org <[EMAIL PROTECTED]> napisa³: >--- Comment #1 from pinskia at gcc dot gnu dot org 2006-09-14 08:05 >--- >#pragma pack(4) >"Variable D is aligned on 4 bytes and should be 8." >No you said to align it to 4 bytes by that pack statement. > >This is not a bug. >Why do you think otherwise? > > Because double have to be aligned on 8 on sparc or bus error occurs. Note that first member of the structure is double. So now I'm not able to assign any value to D.a. If pragma pack regards to all structures then should be some error reported if structure inside pragma pack(4) contain double or long long... Regards Dominik -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29078
[Bug middle-end/29078] wrong alignment with pragma pack(4)
--- Comment #1 from pinskia at gcc dot gnu dot org 2006-09-14 08:05 --- #pragma pack(4) "Variable D is aligned on 4 bytes and should be 8." No you said to align it to 4 bytes by that pack statement. This is not a bug. Why do you think otherwise? -- pinskia at gcc dot gnu dot org changed: What|Removed |Added Severity|critical|normal Status|UNCONFIRMED |RESOLVED Component|c++ |middle-end Known to work|3.4.3 | Resolution||INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29078