[Bug fortran/67170] PRE can't hoist out a readonly argument
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Aug 11 09:12:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67170
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-08-11
Ever confirmed|0 |1
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Ah.
# USE = nonlocal escaped { D.3438 }
# CLB = nonlocal escaped
foo (&D.3438);
As it clobbers nonlocal it clobbers the incoming argument :/ Because of course
as the argument is pointing to possibly global memory it can access it via
other means than through the argument - and the function attribute in use
(".r") just means accesses through the first argument do not modify the
contents pointed to.
I think Fortran guarantees that things passed as argument are not modified
in other ways (or it makes that undefined). Not sure about called functions
though.
Now. In principle I think C says that with
void foo (int * __restrict p)
{
...
bar ();
...
}
bar () can only access *p through the use of p or a derived pointer. So
int x;
bar()
{
x = 1;
}
main()
{
foo (&x);
}
would invoke undefined behavior.
Of course our restrict implementation isn't able to capture that (calls
don't have a clique/base which they would get from the "memory" passed
as reference arguments).
So - confirmed. But no easy way out :(
Old idea about special-casing recursive calls also exists but without clear
idea of what would be legal special alias answers here.
More information about the Gcc-bugs
mailing list