This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Add a new type attribute always_alias (PR79671)
On 04/06/17 20:19, Florian Weimer wrote:
>
> I don't know what your patch does, but your proposed documentation does
> not make this valid because “declared as char” is still not “having no
> declared type”. Or put differently, “behaves like a character type” is
> not what we actually want here.
>
What the patch does is just so simple but it is hard for me to find the
right words so that really everybody understands:
Technically, we already have the may_alias attribute, that forces all
access through pointers to have "alias set 0" that in turn makes all
other objects volatile, unless the compiler can prove that the address
is in fact different. But it has no impact on DECLs, so if you
use may_alias on a type, and you declare an object with that type,
then directly accessing that object by name does NOT have "alias set 0".
When I noticed that in the context of PR79671 I initially thought that
was by accident, but Richi pointed out that this is a useful feature for
vector types, that are always declared as may_alias, and moreover
the may_alias is / has been always documented to have only meaning
on pointers, all that changed is that the TBAA aliasing oracle has
improved recently to follow the specified behavior more closely.
My patch simply duplicates the semantic of may_alias and adds
"alias set 0" for accesses through DECLs of that type.
However, I must confess I find it difficult to understand the
language in which the ISO standard is written.
For instance how do you "declare an object without a declared type"?
> Let me repeat that I don't know if this is merely a documentation issue.
>
> Thanks,
> Florian