public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "soltys at ziu dot info" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/59485] New: may_alias attribute ignored in internal references while defining aggregate types Date: Thu, 12 Dec 2013 14:54:00 -0000 [thread overview] Message-ID: <bug-59485-4@http.gcc.gnu.org/bugzilla/> (raw) 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;
next reply other threads:[~2013-12-12 14:54 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-12-12 14:54 soltys at ziu dot info [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-59485-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).