Original test case was slightly wrong and gratuitously distracting. I've now filed a bug report with a much clearer one: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87191 … and it fits in a tweet: void bar(void *); int foo() { char a[10]; bar(&a+2); }
-
-
Show this threadThanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
oh ffs. post a proper explanation (for those of 1.5k+ that follow you who are there to learn, not blindly hate), delete this crap, or I'll unfollow
-
I love gcc, contribute to it, and don't understand your reaction here, but I'd like to try to. Can you DM or msg me on IRC when it's convenient?
-
I've read your clarifications in the other subthread. Prototype mismatch and irrelevant ipv6 struct usage completely obfuscate your point, as did the ubsan mention. What do you need ubsan's runtime checks for here? This is diagnosable at compile time, as I know you're aware.
-
Indeed, I would love a compile-time warning to catch it (not 100% false-positive free since it could happen in unreachable code, but good enough for me), but couldn't find one, so I tried UBSan to catch it, and also failed.
-
Then I started trying things on godbolt, and UBSan did seem to catch some alternate formulations (which I'd have to try to figure out again now) so I went back to the original bug and minimized the test case to that.
-
struct sockaddr_in6 is not critical to the issue, but it's a good real-world example of a structure containing an array where you could accidentally write &s->a+k instead of s->a+k.
-
OK, here's an example with no sockaddr_in6: https://godbolt.org/z/kvw5zU The situation is actually worse than I thought. gcc 8 and clang *don't* catch it. They just put in a wrong/useless overflow check for overflow past end of addr space (can't happen) not past object size.
-
As I understand, -fsanitize=object-size is included in -fsanitize=undefined and supposed to catch this, but doesn't... ?
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.