[Bug middle-end/60092] posix_memalign not recognized to derive alias and alignment info
rguenther at suse dot de
gcc-bugzilla@gcc.gnu.org
Thu Feb 6 14:07:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60092
--- Comment #9 from rguenther at suse dot de <rguenther at suse dot de> ---
On Thu, 6 Feb 2014, jakub at gcc dot gnu.org wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60092
>
> --- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> (In reply to Richard Biener from comment #7)
> > According to the specification this is wrong. Note that changing errno
> > is hindering optimization. For example
> >
> > int foo (int *p)
> > {
> > *p = 1;
> > malloc (4);
> > return *p;
> > }
> >
> > cannot CSE *p because p may point to errno. (works for float *p and
> > works when using posix_memalign with my patch)
>
> Well, e.g.
> http://pubs.opengroup.org/onlinepubs/007904975/functions/posix_memalign.html
> says nothing about errno, I think only functions which explicitly document not
> to clobber errno may not, all other functions may, but it's value is undefined
> after the call. For calls that are documented to change errno in some cases,
> it is again defined only if those calls return a particular value (e.g. -1),
> otherwise errno is still undefined.
Ok, my manpage says
RETURN VALUE
aligned_alloc(), memalign(), valloc(), and pvalloc() return a
pointer
to the allocated memory, or NULL if the request fails.
posix_memalign() returns zero on success, or one of the error
values
listed in the next section on failure. Note that errno is not set.
so that must be incorrect.
If the value of errno is undefined after posix_memalign that doesn't
help us as we then still cannot CSE.
More information about the Gcc-bugs
mailing list