This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/60092] posix_memalign not recognized to derive alias and alignment info
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 06 Feb 2014 13:42:25 +0000
- Subject: [Bug middle-end/60092] posix_memalign not recognized to derive alias and alignment info
- Auto-submitted: auto-generated
- References: <bug-60092-4 at http dot gcc dot gnu dot org/bugzilla/>
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.