On Thu, Aug 4, 2011 at 2:58 PM, Gabriel Dos Reis <g...@integrable-solutions.net> wrote: > On Wed, Aug 3, 2011 at 1:14 PM, Jason Merrill <ja...@redhat.com> wrote: >> On 08/03/2011 08:46 AM, Richard Guenther wrote: >>> >>> If that's reasonable then adding the malloc attribute should be, too. >>> Finally. Please. Doesn't C++0x maybe "fix" the issue we were >>> discussing to death? >> >> Nope, as far as I can tell nobody raised it with the committee. I have now. >> >> I think we ought to be able to assume that a program which accesses the >> allocated storage other than through the returned pointer has undefined >> behavior. > > Hmm, how do you define "other than the returned pointer"? Do you intend > to rule out garbage collectors? Should not access as raw memory (e.g. through > char* or void*) be allowed?
No. But "other than the returned pointer" should probably "other than through a pointer derived from the returned pointer". >> I think that would be enough for attribute malloc, and I don't >> think that would interfere with reasonable pool allocators. > > I agree we ought to have a form of guarantee a la malloc attribute. Indeed. Otherwise we depend too much on TBAA with all its C++ issues. Richard.