public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "xavier.cooney03 at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111730] erroneous alloc-size-larger-than warning with -O1 Date: Mon, 09 Oct 2023 02:38:40 +0000 [thread overview] Message-ID: <bug-111730-4-Lf4kd4O9pq@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-111730-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111730 --- Comment #4 from Xavier Cooney <xavier.cooney03 at gmail dot com> --- I see, thanks for looking into this. The unreduced test case (which was from a student confused about the error message) was still passing a value to `malloc` which from the context which gcc could see wasn't /necessarily/ non-negative. But the code ``` void foo2(int x) { char *a = malloc(x); (void) a; } ``` doesn't trigger the warning, even though `x` could also be negative. I'm not sure why the extra loops are necessary for the warning to be emitted if the compiler is trying to warn about any time a potentially negative value might be passed to `malloc`. Also the error message reads to me as saying that argument 1 must be in the range [18446744071562067968, 18446744073709551615] (in which case it would be incorrect), rather than saying the argument could be in the range (in which case it would be correct). Thanks again for look into this :)
prev parent reply other threads:[~2023-10-09 2:38 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-10-09 1:12 [Bug c/111730] New: " xavier.cooney03 at gmail dot com 2023-10-09 1:36 ` [Bug c/111730] " pinskia at gcc dot gnu.org 2023-10-09 2:08 ` [Bug tree-optimization/111730] " pinskia at gcc dot gnu.org 2023-10-09 2:15 ` pinskia at gcc dot gnu.org 2023-10-09 2:38 ` xavier.cooney03 at gmail dot com [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-111730-4-Lf4kd4O9pq@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).