public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103964] [9/10/11/12 Regression] OVS miscompilation since r0-92313-g5006671f1aaa63cd Date: Tue, 11 Jan 2022 12:11:53 +0000 [thread overview] Message-ID: <bug-103964-4-xuZGrEfVHP@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-103964-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103964 --- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Ilya Maximets from comment #5) > (In reply to Richard Biener from comment #4) > > the IVOPTs reference is likely due to the fact that while IVOPTs uses > > uintptrs to create the base pointer the TARGET_MEM_REF contained arithmetic > > itself is still considered pointer arithmetic (like also here the embedded > > MEM_REF pointer offsetting) and the base "pointer" cannot be a non-pointer > > to disable that behavior. > > Does this mean that this is UB and the GCC itself relies on a certain result > of it? If GCC through optimizations introduces UB in a code which wasn't there in the user's code, then it would be a GCC bug and something the compiler needs to fix. > Maybe there is a way to not treat a &pos->elem as a pointer arithmetic? > Maybe there should be one? I mean, compilers allows users to perform > computations with offsets of structure fields where the base pointer > is NULL, and NULL obviously doesn't point to any valid object. I'm not > sure if it's an UB or not, but constructions like '&((struct s > *)NULL)->field' > are very common. &((struct s *)NULL)->field is not valid in C or C++, but for many years the offsetof macro which is valid in those has been defined like that and various projects occassionally still use the above, so GCC supports those as an extension (poor man's offsetof). See e.g. spots with comments like Cope with user tricks that amount to offsetof. etc. in GCC sources. That doesn't change anything about this case, the poor man's offsetof is folded into a constant very early (well, with variable offsets in array refs in there could also into an expression, but still integral expression, the pointer arithmetics is gone from there). What is the reason why OVS (and kernel) doesn't use 2 variables, one for the iterator that is a pointer to the prev/next structure only and one assigned e.g. in the condition from the iterator that is used only when it isn't the start? At least if targetting C99 and above (or C++) one can declare one of those iterators in the for loop init expression...
next prev parent reply other threads:[~2022-01-11 12:11 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-01-10 15:12 [Bug tree-optimization/103964] New: " jakub at gcc dot gnu.org 2022-01-10 15:18 ` [Bug tree-optimization/103964] " fw at gcc dot gnu.org 2022-01-10 15:58 ` jakub at gcc dot gnu.org 2022-01-11 2:52 ` pinskia at gcc dot gnu.org 2022-01-11 8:15 ` rguenth at gcc dot gnu.org 2022-01-11 8:38 ` rguenth at gcc dot gnu.org 2022-01-11 11:19 ` i.maximets at ovn dot org 2022-01-11 12:11 ` jakub at gcc dot gnu.org [this message] 2022-01-11 13:58 ` i.maximets at ovn dot org 2022-01-11 14:06 ` rguenth at gcc dot gnu.org 2022-01-11 14:47 ` jakub at gcc dot gnu.org 2022-01-11 16:46 ` i.maximets at ovn dot org 2022-01-11 17:00 ` jakub at gcc dot gnu.org 2022-01-11 17:10 ` i.maximets at ovn dot org 2022-01-11 17:57 ` jakub 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-103964-4-xuZGrEfVHP@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).