Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #146685
| From | scott@slp53.sl.home (Scott Lurndal) |
|---|---|
| Subject | Re: Indexing one past the end of array? |
| Newsgroups | comp.lang.c |
| References | <gF6mF.2635984$c8w1.2556225@fx08.am4> <qncvpj$sj9$1@news.albasani.net> |
| Message-ID | <28HmF.42374$oA2.30129@fx08.iad> (permalink) |
| Organization | UsenetServer - www.usenetserver.com |
| Date | 2019-10-07 13:32 +0000 |
"Oliver S." <Follow.Me@gmx.net> writes: >> Elsewhere, I've read that on embedded systems memory can be allocated >> right up to the end of memory, and therefore such indexes are invalid >> (but I cannot remember where). >> So, is it always legal to calculate one past the end of an array or >> allocated memory? >> [1] https://lwn.net/Articles/278137/ > >Userspace has its addresses ussually in the lower part of the logical >address-space, so addresses calculated to be above an array would never >wrap-around. >In kernel-space addresses could wrap-around but I think a proper ker- >nel would reserve a reasonable amount of memory at top of the logical >address-space so that a past-the-end-pointer would maximally point >into that area and not wrap around. Most of them mark the first page of the virtual address space as not-present to catch inadvertent wrapping behavior. On the physical address side, both ARM and Intel will use unsigned modulo arithmetic, so addresses will simply wrap.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Indexing one past the end of array? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2019-10-06 04:02 +0800
Re: Indexing one past the end of array? Keith Thompson <kst-u@mib.org> - 2019-10-05 13:13 -0700
Re: Indexing one past the end of array? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-10-05 22:01 +0100
Re: Indexing one past the end of array? Keith Thompson <kst-u@mib.org> - 2019-10-05 14:35 -0700
Re: Indexing one past the end of array? Richard Damon <Richard@Damon-Family.org> - 2019-10-05 19:00 -0400
Re: Indexing one past the end of array? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-10-06 08:05 -0700
Re: Indexing one past the end of array? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-10-06 06:36 -0700
Re: Indexing one past the end of array? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-10-06 16:31 +0100
Re: Indexing one past the end of array? Richard Damon <Richard@Damon-Family.org> - 2019-10-05 17:10 -0400
Re: Indexing one past the end of array? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-10-06 07:40 -0700
Re: Indexing one past the end of array? Mateusz Viste <mateusz@wont.tell> - 2019-10-05 20:26 +0000
Re: Indexing one past the end of array? chad <cdalten@gmail.com> - 2019-10-05 16:55 -0700
Re: Indexing one past the end of array? "Oliver S." <Follow.Me@gmx.net> - 2019-10-06 15:50 +0200
Re: Indexing one past the end of array? "Oliver S." <Follow.Me@gmx.net> - 2019-10-06 17:04 +0200
Re: Indexing one past the end of array? scott@slp53.sl.home (Scott Lurndal) - 2019-10-07 13:32 +0000
Re: Indexing one past the end of array? "Oliver S." <Follow.Me@gmx.net> - 2019-10-07 17:23 +0200
csiph-web