This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/35427] pointer subtraction in very big array
- From: "akr at m17n dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Mar 2008 23:45:19 -0000
- Subject: [Bug c/35427] pointer subtraction in very big array
- References: <bug-35427-2489@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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