public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/59485] New: may_alias attribute ignored in internal references while defining aggregate types
@ 2013-12-12 14:54 soltys at ziu dot info
2022-01-10 9:10 ` [Bug c/59485] " pinskia at gcc dot gnu.org
2022-01-31 16:03 ` marxin at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: soltys at ziu dot info @ 2013-12-12 14:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59485
Bug ID: 59485
Summary: may_alias attribute ignored in internal references
while defining aggregate types
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: soltys at ziu dot info
Note, I first asked about it on gcc-help, though got no responsens. This does
look like a bug - though obviously I'm not sure if it really should be
considered as such.
Anyway, consider following piece of code:
struct __attribute__((may_alias)) tag_si {
int y;
};
struct __attribute__((may_alias)) tag_s {
int x;
struct tag_si *pi;
struct tag_s *p;
};
int main(void)
{
struct tag_s test = {0};
struct tag_si **ppi;
struct tag_s **pp;
ppi = &test.pi; /* ok */
pp = &test.p; /* will generate warning */
return 0;
}
The possible problem with the above example, is that pp assignment will cause
compiler to emit:
test.c: In function 'main':
test.c:18:12: warning: assignment from incompatible pointer type [enabled by
default]
pp = &test.p;
^
At the same time analogous ppi assignment gives no issues. The only difference
between "tag_si" and "tag_s" is that the former is defined first outside and
then referenced in subsequent definition - while the latter is referenced
during its definition - and then it "forgets" about may_alias attribute (thus
pp = &test.p gives warrning).
I tried to workaround it with preceeding struct forward declaration, e.g.
struct __attribute__((may_alias)) tag_s;
struct __attribute__((may_alias)) tag_s { ......
But this approach has no effect either.
The only workaround for that I found is extra typedef with may_alias and type
cast, e.g.:
typedef struct tag_s *tag_t_pa __attribute__((may_alias));
tag_t_pa *pp;
pp = (tag_t_pa *)&test.p;
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/59485] may_alias attribute ignored in internal references while defining aggregate types
2013-12-12 14:54 [Bug c/59485] New: may_alias attribute ignored in internal references while defining aggregate types soltys at ziu dot info
@ 2022-01-10 9:10 ` pinskia at gcc dot gnu.org
2022-01-31 16:03 ` marxin at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-10 9:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59485
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |needs-bisection
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Seems fixed in GCC 7+.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/59485] may_alias attribute ignored in internal references while defining aggregate types
2013-12-12 14:54 [Bug c/59485] New: may_alias attribute ignored in internal references while defining aggregate types soltys at ziu dot info
2022-01-10 9:10 ` [Bug c/59485] " pinskia at gcc dot gnu.org
@ 2022-01-31 16:03 ` marxin at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-01-31 16:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59485
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
CC| |marxin at gcc dot gnu.org
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Fixed with r7-1272-g5545a9071573a58e.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-31 16:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-12 14:54 [Bug c/59485] New: may_alias attribute ignored in internal references while defining aggregate types soltys at ziu dot info
2022-01-10 9:10 ` [Bug c/59485] " pinskia at gcc dot gnu.org
2022-01-31 16:03 ` marxin at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).