[Bug c/35427] pointer subtraction in very big array
akr at m17n dot org
gcc-bugzilla@gcc.gnu.org
Mon Mar 3 23:46:00 GMT 2008
------- Comment #2 from akr at m17n dot org 2008-03-03 23:45 -------
(In reply to comment #1)
> nelem*sizeof(long)
>
> Wraps so what do you expect? This is the correct behavior really.
Oops. It wrapped.
But changing the type of nelem to size_t doesn't change the situation.
nelem * sizeof(long) < 2**32, so it doesn't wraps size_t.
Anyway malloc's argument is size_t.
So we can pass a size bigger than 2**31 bytes and malloc can allocates it.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35427
More information about the Gcc-bugs
mailing list