Message-ID: <3B3A1E84.A12C5FCA@sensor.com> From: Ron Natalie X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: DJGPP reserves wrong int size References: <9dde68b7 DOT 0106241053 DOT 2a385311 AT posting DOT google DOT com> <3B3A1B39 DOT F4D0F58B AT stud DOT ntnu DOT no> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 47 Date: Wed, 27 Jun 2001 13:57:24 -0400 NNTP-Posting-Host: 156.40.240.200 X-Trace: mencken.net.nih.gov 993664476 156.40.240.200 (Wed, 27 Jun 2001 13:54:36 EDT) NNTP-Posting-Date: Wed, 27 Jun 2001 13:54:36 EDT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Kent Dahl wrote: > > 00000000 55 push ebp > > 00000001 89E5 mov ebp,esp > > 00000003 83EC04 sub esp,byte +0x18 > > 00000006 C745FC78563412 mov dword [ebp-0x4],0x12345678 > > 0000000D C9 leave > > 0000000E C3 ret > > > > The third line reserves 18 bytes. > > Does it? First of all, its 0x18 bytes, aka 24 bytes. > Are you sure it isn't just padding for alignment? If you read before posting, you'll see the third line allocates 4 bytes. 83 is the opcode for immediate subtract, where the EC indicates the register ESP operand and 04 is the value 4 being s subtracted. > > If I add yet another int, the number doesn't increase... > > > int main () > { > int i; > i = 0x12345678; > int j; > j = 0xCAFEBABE; > } > > Gee, my G++ 2.91.66 does no such thing. It allocates exactly 4 (with the similar code as the original poster) and 8 with the above code. Of course, this is really all quite a silly discusion, if you turn on the optimizer, it emits main: pushl %ebp movl %esp,%ebp xorl %eax, %eax leave ret I.e., it doesn't allocate anything. It realizes you aren't doing anything with either one of those variables and optimizes them both away.