delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/12/31/07:42:16

From: "A. Jans-Beken" <jansb000 AT wxs DOT nl>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Array Addressing Bug in DJGPP 2.02 with GCC 2.81 ???
Date: Thu, 31 Dec 1998 13:25:28 +0100
Organization: World Access
Lines: 45
Message-ID: <368B6D38.2C66A48@wxs.nl>
References: <MPG DOT 10f0f90c10857f59989685 AT news DOT feist DOT com> <767k28$e46$1 AT latinum DOT dresearch DOT de> <MPG DOT 10f198f2fe08ca15989686 AT news DOT feist DOT com>
NNTP-Posting-Host: vl0210-0.dial.wxs.nl
Mime-Version: 1.0
X-Trace: reader1.wxs.nl 915107525 24596 195.121.18.210 (31 Dec 1998 12:32:05 GMT)
X-Complaints-To: abuse AT wxs DOT nl
NNTP-Posting-Date: 31 Dec 1998 12:32:05 GMT
X-Mailer: Mozilla 4.04 [en] (Win95; I)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

BJC wrote:

> In article <767k28$e46$1 AT latinum DOT dresearch DOT de>, beck AT dresearch DOT de says...
> > No, sorryly this is a bug in you :-)
>
> heh, it figures ;-)
>
> > >i compiled this program with DJGPP 2.01 and PGCC 1.01 and all was
> > well...infact it left 2
> > >bytes space between str2 and str1.
> >
> > It's difficult to say why. Maybe the optimizers in this compilers think,
> > that the strings should be allocated
> > 8 bytes aligned...
>
> hmm...
>

Actually the compiler should optimize to 4 byte boundaries. Remember str1 - its
5 bytes. This will be rounded up to the nearest multiple of 4 (which is 8). Your
str2 happens to be exactly 4 bytes so no optimization is needed.

In the DJGPP faq it is stated that optimizing to 4 byte boundaries is needed to
gain a big speed increase in program execution (it is a 32-bit compiler). If you
really are low on memory you may instruct the compiler explicitly to not
optimize to 4-byte boundaries with the __packed__ attribute. Read all about this
in the docs that came with djgpp.

> > So the problem is your for loop. Note, that in C the typical construct for
> > traversing n elements is
> > for (i = 0; i < n; ++i)
>
> JonnyCarsonMode(tm) ON
> "oh, i did not know that."
> JonnyCarsonMode(tm) OFF
>
> heehee, well like i said i'm still new to programming.
> Thanks for the replys!!
>
> --
> brian james chapman
> email: bchapman(at)feist(dot)com



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019