Bug 115498 - Missing warning for comparing distinct (char*) pointers in much complex code path
Summary: Missing warning for comparing distinct (char*) pointers in much complex code ...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: unknown
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: new-warning, new_warning
  Show dependency treegraph
 
Reported: 2024-06-15 02:04 UTC by Sam James
Modified: 2024-10-01 04:36 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-06-15 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James 2024-06-15 02:04:33 UTC
This is from an intermediate bad reduction in another PR: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115137#c5

```
enum { a } b;
int d, e;
static void f(char *g, char *h) {
    for (; g < h; g++) /* Comparison of two distinct & disjoint pointers */
        if (b)
            ++d;
}
int main() { f("somepage.html", "" + e); }
```

We don't warn on comparing these distinct pointers.

I suppose it might be hard to do this in general without some aliasing sanitizer, but for constant pool references, it should be okay?
Comment 1 Andrew Pinski 2024-06-15 02:07:23 UTC
Confirmed. This warning can't be done in the front-end. It might become as useless as strict aliasing and strict overflows were ...