This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: struct
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Andrew Haley <aph at redhat dot com>
- Cc: sundaresh <sundaresh at mail dot com>, gcc-help at gcc dot gnu dot org
- Date: Mon, 1 Oct 2018 04:14:22 -0500
- Subject: Re: struct
- References: <1538329498465-0.post@n8.nabble.com> <e0365893-e7a6-ab68-26e5-2ea33dae64bb@redhat.com>
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