This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/35427] pointer subtraction in very big array



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]