This is the mail archive of the gcc-help@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: struct


On Mon, Oct 01, 2018 at 09:16:33AM +0100, Andrew Haley wrote:
> On 09/30/2018 06:44 PM, sundaresh wrote:
> > Why do struct's take up a lot more memory than the sum of the sizes of its
> > members ? This increases by even a lot more the larger the struct gets . If
> > the compiler is doing padding or aligning I would like to disable and not
> > have that at all since it is unnecessarily wasteful of memory ? I
> > encountered a similar problem when declaring floating point variables
> > independently outside a struct. The problem becomes worse if these floating
> > point variables are struct members.
> 
> Alignment, usually. But it's worth noting that GCC follows the system
> ABI specfication for laying out structures in memory. We usually don't
> get to decide how it's done.

It also sounds like sundaresh is dealing with x87 doubles.


Segher


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