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 sanitizer/113214] false-positive -Wstringop-overflow warning with thread sanitizer Date: Mon, 05 Feb 2024 18:38:30 +0000 [thread overview] Message-ID: <bug-113214-4-cMAVlh3twd@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-113214-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113214 --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I think the reason for the warning is fre5 optimizing _21 = &MEM[(struct xe_gt *)uc_8(D) + -2072B].tile; ... - _20 = uc_8(D) + 18446744073709549544; - _2 = _20 + _19; + _2 = _21 + _19; ... _5 = _4 * 4; _6 = _2 + _5; ... MEM <uint128_t> [(char * {ref-all})_6] = _13; and the -Wstringop-overflow warning stuff (done during the strlen pass) considering it then to be access into the tile member rather than anywhere into the structure. Sure, if one writes: void foo (struct xe_gt *p, int i) { uint128_t *q = (uint128_t *) &p->tile; q += i; *q = 0; } in the source, then it will be UB not just because of the most likely aliasing violation, but also because the pointer in some kind of Martin's strict reading is just to the particular element rather than whole structure. But void baz (struct xe_tile **); void bar (struct xe_gt *p, int i) { baz (&p->tile); uint128_t *q = (uint128_t *) p; q += i; *q = 0; } should be fine. The reason it doesn't trigger without -fsanitize=thread is that then nothing takes address of the &(uc + cst)->tile in that case, it is just read, so there is nothing to CSE. Before IPA we try to maintain what the address taking refers to exactly for builtin {,dynamic} object size 1/3 modes, but afterwards such distinctions are lost.
prev parent reply other threads:[~2024-02-05 18:38 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-03 11:46 [Bug sanitizer/113214] New: " arnd at linaro dot org 2024-01-03 21:51 ` [Bug sanitizer/113214] " pinskia at gcc dot gnu.org 2024-02-05 16:49 ` arnd at linaro dot org 2024-02-05 18:38 ` jakub at gcc dot gnu.org [this message]
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-113214-4-cMAVlh3twd@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).